题解 | 计算日期到天数转换
计算日期到天数转换
https://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded
import sys s = input().split(" ") n = int(s[0]) if n % 400 == 0 or (n % 100 != 0 and n % 4 == 0): run = True else: run = False y = int(s[1]) big = 31 normal = 30 small = 29 if run else 28 d = { big:[1,3,5,7,8,10,12], normal:[4,6,9,11], small:[2] } res = 0 for k,v in d.items(): for _ in v: if y > _: res += k print(res+int(s[2]))
哈希