Friday the 13th
InterviewTime limit1sMemory limit512 MB
Count every Friday the 13th from 2019 through year N, given Jan 1, 2019 is a Tuesday and the leap-year rules.
- Level
Medium4 of 10
- Topics
- Math, Simulation, Implementation
- Solved
- No attempts yet
Problem
Jaeun is the neighborhood's notorious occult enthusiast. Always reading occult books in the library and attending an extraterrestrial artifacts study group, Jaeun one day heard an enormous rumor. The rumor was a prophecy about the future of Earth, and according to it, Earth may be destroyed unless someone counts the number of upcoming Friday the 13ths starting from 2019. Overflowing with consideration as usual, Jaeun decided to record, for his descendants as well as himself, the cumulative number of Friday the 13ths up to 100,000 AD for every year. But Jaeun is weak at arithmetic and left all the calculations to us. Help Jaeun by computing and reporting the cumulative number of Friday the 13ths from 2019 to year N.
Input
The first line contains the integer N. (2019 ≤ N ≤ 100,000)
Output
On the first line, print the cumulative number of Friday the 13ths from 2019 to year N.
Hints
- January 1, 2019 is a Tuesday.
- A year in which February has 29 days is called a leap year.
- In general, the months from January to December have 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 days respectively. In a leap year, February has 29 days instead of 28.
- A year divisible by 400 is a leap year.
- A year divisible by 100 but not by 400 is not a leap year.
- A year divisible by 4 but not by 100 is a leap year.
- Any other year is not a leap year.