Jane is visiting your cubicle when she spies the Elvis calendar hanging on your wall.
"That's not right, is it?" she asks rhetorically.
Your Elvis calendar says that September 8 is a Sunday, but it's actually a Monday. Elvis Presley, the King of Rock 'n' Roll, is no liar. It's just that you bought the calendar last year. This is a 2002 calendar, whereas the current year is 2003. The dates no longer match the days of the week! But there will come a year when every date falls on the same day of the week as in 2002, and the King will reign again.
Given an int representing a year between 2002 and 9999, return the closest future year with which it shares a calendar. Jane reminds you that there are 30 days in April, June, September, and November. The remaining months, with the exception of February, have 31 days. February has 29 days in leap years, and 28 days otherwise. Leap years are divisible by four, and not divisible by 100 unless they are also divisible by 400. For example, 2004 and 2400 are leap years, but 2003 and 2100 are not. Jane also points out that there are only 14 possible calendars.
|