CalendarRecycle
SRM 163 · 2003-09-08 · by Eeyore
Problem Statement
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
Constraints
- year is between 2002 and 9999, inclusive
2002 Returns: 2013
Your 2002 Elvis calendar will be valid again in 2013. The following table shows the day of the week that September 8th falls on each year from 2002 to 2013. Year | Day -----+----- 2002 | Sunday 2003 | Monday 2004 | Wednesday 2005 | Thursday 2006 | Friday 2007 | Saturday 2008 | Monday 2009 | Tuesday 2010 | Wednesday 2011 | Thursday 2012 | Saturday 2013 | Sunday
2013 Returns: 2019
After 2013, your 2002 Elvis calendar will next be valid in 2019.
2008 Returns: 2036
9999 Returns: 10010
2525 Returns: 2531
Submissions are judged against all 110 archived test cases, of which 5 are shown here. Case numbers match the judge’s.
Language: C++17 · define a public class CalendarRecycle with a public method int useAgain(int year) · 110 test cases · 2 s / 256 MB per case