D-Day
InterviewTime limit2sMemory limit128 MB
Compute the number of days between two calendar dates accounting for leap years, printing 'gg' if the gap reaches 1000 years or more.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
Yujin is attending a camp and wants to know how many days remain from today until the day the camp ends, the D-Day. The camp may last for a very long time and may include leap years, so counting the days by hand is difficult.
Leap years are determined by the following rules.
- A year divisible by 4 is a leap year.
- However, a year divisible by 100 is a common year.
- However again, a year divisible by 400 is a leap year.
If the camp lasts for at least 1000 years, Yujin decides not to wait any longer.
Input
The first line contains today's date. The second line contains the D-Day date.
Each date is given as year month day, with the three integers separated by spaces. Every date is valid and lies between January 1, year 1 and December 31, year 9999, inclusive. Today's date is always earlier than the D-Day date.
Output
If x days remain from today until D-Day, print D-x.
If the camp lasts for at least 1000 years, print gg instead. More precisely, if today is year y, month m, day d and the D-Day date is the same as or later than year y+1000, month m, day d, print gg. Today's date is never February 29.