Algorithm/lanqiao/test/2020省回文日期.py
2022-04-09 01:07:54 +08:00

25 lines
507 B
Python

import io
import sys
sys.stdin = io.StringIO('20200202')
import datetime
s_in = input()
year, month, day = int(s_in[:4]), int(s_in[4:6]), int(s_in[-2:])
now = datetime.date(year, month, day)
one_day = datetime.timedelta(days=1)
reverse = True
while True:
now += one_day
s = str(now).replace('-', '')
if reverse and s[::] == s[::-1]:
print(s)
reverse = False
# ABABBABA
if s[0] == s[2] == s[5] == s[7] and s[1] == s[3] == s[4] == s[6]:
print(s)
break