eolymp
bolt
Спробуйте наш новий інтерфейс для відправки розв'язків
Задачі

Palindromic Dates

Palindromic Dates

A date is said to be palindromic if, when written in the form "\textbf{YearMMDD}", the result is a palindrome (a number that has the same value regardless if we read it left-to-right or right-to-left). For example, the date "\textbf{January 1^st, 1}" is palindromic since it would be written as "\textbf{10101}"; "\textbf{December 1^st, 1021}" is palindromic too, since it would be written as "\textbf{10211201}". Given a date, you are required to find the next valid date (in chronological order) that is palindromic (according to the definition of "palindromic date" that was given in the previous paragraph). For the purpose of this problem, a date is considered valid if the year is between \textbf{1} and \textbf{2147483647}, the month is between \textbf{1} and \textbf{12}, the day is at least 1and: \begin{itemize} \item for months \textbf{1}, \textbf{3}, \textbf{5}, \textbf{7}, \textbf{8}, \textbf{10}, \textbf{12} -- the day is not greater than \textbf{31} \item for months \textbf{4}, \textbf{6}, \textbf{9}, \textbf{11} -- the day is not greater than \textbf{30} \item for month 2, the day is not greater than \textbf{29}, and can be \textbf{29} only during leap years. A year is considered "leap year" if it is divisible by \textbf{400}, or is divisible by \textbf{4} but not by \textbf{100}. \end{itemize} \InputFile The input file contains one date per line: thee numbers separated by the character '\textbf{/}', representing (in order) the day, month and year. For example, July \textbf{4}^th \textbf{2011} would be written as "\textbf{04/07/2011}" (or \textbf{4/07/2011}, or \textbf{4/7/2011}). The last line in the input file is empty. \OutputFile The output file shall contain the next valid palindromic date for each date in the input file, one date per line. The date format in the output file is \textbf{DD/MM/Year} -- i.e. the separator character is '\textbf{/}', the year’s first digit must never be \textbf{0}, and you must always use two digits for day and month (use \textbf{01} instead of \textbf{1}, \textbf{02} instead of \textbf{2} etc.). It is guaranteed that all input dates are valid, and that for all input dates there is a "next valid palindromic date".
Ліміт часу 1 секунда
Ліміт використання пам'яті 64 MiB
Вхідні дані #1
1/1/1
12/11/1
01/06/138048967
Вихідні дані #1
01/02/1
11/12/1
31/08/138048984
Джерело SEERC-2011