All submissions for this problem are available.
Mo is a firm believer of existence of ghosts. To solidify this, he was born on a Friday the 13th. His current age is greater than or equal to x years and the current year is 2014(January 16). Find Mo's youngest age possible and thus the corresponding year and month of birth.
There are few facts you need to know before you can solve this problem:
1)January 1, 1900 was on a Monday.
2)Thirty days has September, April, June, and November, all the rest have 31 except for February which has 28 except in leap years when it has 29.
3)Every year evenly divisible by 4 is a leap year (1992 = 4*498 so 1992 will be a leap year, but the year 1990 is not a leap year)
4)The rule above does not hold for century years. Century years divisible by 400 are leap years, all other are not. Thus, the century years 1700, 1800, 1900 and 2100 are not leap years, but 2000 is a leap year.
The first line contains T the number of test cases. T lines follow. Each line describes a test case with the integer x.
Output the number of the month and year of birth.
- 1 ≤ T ≤ 100
- 0 ≤ T ≤ 114
Input: 2 2 11 Output: 5 2011 7 2001
Example case 1.
In this case, Mo was born on May 2011.
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.