eolymp
bolt
Try our new interface for solving problems
Məsələlər

First Date

First Date

In \textbf{1582}, pope Gregory XIII decreed a calendar reform to bring the mean length of the calendar year (counted in days) more in line with the actual number of days in an astronomical year. This calendar reform entailed a transition from the Julian calendar to the Gregorian calendar. Both the Julian and Gregorian calendars have regular years with \textbf{365} days, and so-called leap years with \textbf{366} days. In regular years, the month February has 28 days, while in leap years, it has an extra 'leap day': February \textbf{29}^th. The single difference between the Julian and Gregorian calendars is in their rule to determine if a year is a leap year. In the Julian calendar, leap years are those years that are divisible by \textbf{4}. The Gregorian calendar’s rule for determining leap years is a bit more complicated: years divisible by \textbf{4} are leap years, unless they are divisible by \textbf{100} but not by \textbf{400}. Following these rules, the years \textbf{1600}, \textbf{1700}, \textbf{1800}, \textbf{1900}, \textbf{2000}, \textbf{2100}, \textbf{2200}, \textbf{2300}, and \textbf{2400} are all leap years in the Julian calendar. In the Gregorian calendar, the only leap years in this list are \textbf{1600}, \textbf{2000}, and \textbf{2400}. The old Julian calendar has a mean year length of \textbf{365.25} days, while the new Gregorian calendar has a mean year length of \textbf{365.2425} days. Given that the actual number of days in an astronomical year is about \textbf{365.24219} days, you can see why the Gregorian calendar is an improvement. As part of the Gregorian reform, a number of dates were skipped, to reverse the effects of having used the Julian calendar for over \textbf{1500} years. Specifically, the Gregorian reform decreed that October \textbf{4}, \textbf{1582} (Julian) was to be followed by October \textbf{15}, \textbf{1582} (Gregorian). However, by the end of the \textbf{16}^th century the Reformation was in full swing. While the Catholic countries tended to follow the Papal decree, many countries continued using the Julian calendar until much later. For example, the United Kingdom switched from the Julian calendar to the Gregorian calendar on September \textbf{2}, \textbf{1752} (Julian) which was followed by September \textbf{14}, \textbf{1752} (Gregorian) --- by that time, \textbf{11} dates had to be skipped to make the switch. The last European country to switch was Greece, which made the transition as late as February \textbf{15}, \textbf{1923} (Julian) which was followed by March \textbf{1}, \textbf{1923} (Gregorian), skipping \textbf{13} dates. Given the last day for which the Julian calendar is in effect for some country (expressed as a Julian date), determine the next day’s Gregorian date, i.e., the first date that uses the Gregorian calendar. \InputFile For each test case, the input consists of one line containing a date in the Julian calendar, formatted as \textbf{YYYY-MM-DD}. This date will be no earlier than October \textbf{4}, \textbf{1582}, and no later than October \textbf{18}, \textbf{9999}. The given date represents the last day that the Julian calendar is in effect for some country. \OutputFile For each test case, print the first Gregorian date after the calendar transition.
Zaman məhdudiyyəti 1 saniyə
Yaddaşı istafadə məhdudiyyəti 128 MiB
Giriş verilənləri #1
1582-10-04
1752-09-02
1900-02-25
1923-02-15
Çıxış verilənləri #1
1582-10-15
1752-09-14
1900-03-10
1923-03-01
Mənbə ACM ICPC NWERC 2013