题解 | 计算日期到天数转换

计算日期到天数转换

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]))

哈希

全部评论

相关推荐

缒梦&独舞:这家公司是这样的,去年给我实习offer了,不过也是面着玩儿的,他周六还要去做公益志愿活动
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务