I Flipped The Calendar...
Time limit2sMemory limit2048 MB
Given a year from 1970 to 2037, count the rows the twelve monthly calendar sheets need when each week starts on Monday.
- Level
Easy2 of 10
- Topics
- Implementation, Math
- Solved
- No attempts yet
Problem
Nikolai was flipping through a calendar when he wondered how many rows the calendar has for a given year.
The calendar has 12 sheets, one for each month from January to December. Each sheet lists every day of its month. Days are arranged in rows by week, so the days of one week share a row and the days of different weeks are in different rows. In this calendar, a week starts on Monday.
For example, if a month has 31 days and its first day is a Sunday (as in January 2023), the sheet for that month has six rows:
A leap year has 29 days in February, and a non-leap year has 28. A year is a leap year if its number is divisible by 400, or divisible by 4 but not by 100. For example, 2000, 2004, and 2040 are leap years, while 1900, 1982, and 2039 are not.
Input
The first line contains the year ().
Output
Print the number of rows in the calendar for the given year.