AcWing 466. 回文日期
原题链接
简单
作者:
二十六
,
2025-04-05 18:45:46
· 辽宁
,
所有人可见
,
阅读 1
from datetime import date
from datetime import timedelta
def is_legal_date(date_string):
year = int(date_string[:4])
month = int(date_string[4:6])
day = int(date_string[6:])
try:
date(year, month, day)
return True
except ValueError:
return False
start = input()
end = input()
cnt = 0
for try_date_half in range(10000):
try_date_half = '{:0>4}'.format(try_date_half)
try_date = try_date_half[::-1] + try_date_half
if try_date >= start and try_date <= end and is_legal_date(try_date):
cnt += 1
print(cnt)