#P8716. [蓝桥杯 2020 省 AB2] 回文日期
[蓝桥杯 2020 省 AB2] 回文日期
Problem Description
During the 2020 Spring Festival, a special date caught everyone’s attention: February 2, 2020. Because if we write this date in the yyyymmdd format as an -digit number, it is 20200202, which happens to be a palindrome. We call such dates palindrome dates.
Some people said that 20200202 is a “once in a thousand years” special day. Xiao Ming does not agree, because less than 2 years later, there is the next palindrome date: 20211202, which is December 2, 2021.
Others said that 20200202 is not only a palindrome date, but also an ABABBABA-type palindrome date. Xiao Ming also does not agree, because after about years, you can meet the next ABABBABA-type palindrome date: 21211212, which is December 12, 2121. It is not “once in a thousand years”, at most “twice in a thousand years”.
Given an -digit date, please compute what day is the next palindrome date after this date, and what day is the next ABABBABA-type palindrome date after this date.
Input Format
The input contains an eight-digit integer , representing a date.
Output Format
Output two lines, each with one eight-digit number. The first line is the next palindrome date. The second line is the next ABABBABA-type palindrome date.
20200202
20211202
21211212
Hint
For all test cases, , and it is guaranteed that is an -digit number representing a valid date.
Lanqiao Cup 2020 Second Round Provincial Contest, Group A Problem G (Group B Problem G).
Translated by ChatGPT 5