题解 | #百钱买百鸡问题#

计算日期到天数转换

http://www.nowcoder.com/practice/769d45d455fe40b385ba32f97e7bcded

def dfx(ipp):
    ip = ipp.split(" ")
    yf = int(ip[1])
    ts = 0
    for _ in range(1,yf):
        if _ == 1:
            ts += 31
        if _ == 2:
            ts += 28
        if _ == 3:
            ts += 31
        if _ == 4:
            ts += 30
        if _ == 5:
            ts += 31
        if _ == 6:
            ts += 30
        if _ == 7:
            ts += 31
        if _ == 8:
            ts += 30
        if _ == 9:
            ts += 31
        if _ == 10:
            ts += 31
        if _ == 11:
            ts += 30
        if _ == 12:
            ts += 31
    if int(ip[0]) % 4== 0:
        ts += 1
    if int(ip[0]) % 100 == 0:
        ts -= 1
    ts += int(ip[2])
              
    return ts
while True:
    try:
        print(dfx(input()))   
    except:
        break

全部评论

相关推荐

点赞 收藏 评论
分享
牛客网
牛客企业服务