题解 | 计算一年中的第几天

计算一年中的第几天

https://www.nowcoder.com/practice/178aa3dafb144bb8b0445edb5e9b812a

from datetime import date
import sys

# for line in sys.stdin:
#     a = line.split()
#     print(int(a[0]) + int(a[1]

nums = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
for dates in sys.stdin:
    dat = list(map(int, dates.split()))
    ans = 0
    if not dat[0] % 100 or not dat[0] % 4 or not dat[0] % 400:
        nums[1] = 29
    for i in range(dat[1] - 1):
        ans += nums[i]
    ans += dat[2]
    print(ans)

全部评论

相关推荐

合适才能收到offe...:招聘上写这些态度傲慢的就别继续招呼了,你会发现hr和面试官挺神的,本来求职艰难就可能影响一些心态了,你去这种公司面试的话,整个心态会炸的。
点赞 评论 收藏
分享
03-26 19:49
吉林大学 Java
elliot19:确实是这样,上次就纯聊天,问项目实习做啥,最后掏了一道非hot100的hard第二天挂,今晚复活重新一面
查看6道真题和解析
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务