牛客16438 回文日期
生活随笔
收集整理的這篇文章主要介紹了
牛客16438 回文日期
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
date1 = input()
date2 = input()"""
判斷是否是閏年
"""
def isLeap(year):if (year%4 == 0 and year%100 != 0) or (year%400 == 0):return 1else:return 0"""
判斷是否是回文數(shù)
"""
def isPalindrome(year):for i in range(4):if year[7-i] != year[i]:return 0return 1ans = 0
y1 = int(date1[0:4])
y2 = int(date2[0:4])for year in range(y1, y2+1):if isLeap(year):D = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]else:D = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] y = str(year)date = int(y + y[::-1])#date = year*10000 + year%10*1000 + year%100//10*100 + year%1000//100*10 + year//1000;#date = int(year*10000 + int(y[3])*1000 + int(y[2])*100 + int(y[1])*10 + int(y[0]))#print(date)if(int(date1) <= date <= int(date2) and 0 < (date%10000//100) <= 12 and isPalindrome(str(date)) and date%100 <= D[date%10000//100-1]):ans = ans + 1;
print(ans)
總結(jié)
以上是生活随笔為你收集整理的牛客16438 回文日期的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Unity3D-相关函数功能
- 下一篇: 牛客14342 神奇的数字