November 11
InterviewTime limit2sMemory limit1024 MB
For each year and month, find the date that is m days before month m, day m of that year, using the calendar with leap-year rules.
- Level
Easy2 of 10
- Topics
- Implementation, Simulation
- Solved
- No attempts yet
Problem
On November 11, there are several observances: Farmers' Day, Garaetteok Day, Pedestrian Day, the founding anniversary of the Republic of Korea Navy, the Memorial Day for UN Veterans, and Pepero Day. Seonghyeon found that 11 days before November 11 is October 31, which is Halloween. He plans to get Pepero from a friend on the next Halloween.
Seonghyeon wondered whether another special day exists at the date days before month , day , like November 11. Write a program that finds the date days before month , day .
The months 1, 3, 5, 7, 8, 10, and 12 have 31 days. The months 4, 6, 9, and 11 have 30 days. February has 28 days in a common year and 29 days in a leap year. A leap year is a year that is a multiple of 4 but not a multiple of 100, or a multiple of 400.
Input
The first line contains the number of dates to compute. ()
From the second line, lines follow, each giving one date. Each date is given as a year and a month , separated by a space. (, )
Output
Print lines.
On line , print the year, month, and day, separated by spaces, of the date that is days before month , day of year .