求助第9个检查点

P5707 【深基2.例12】上学迟到

lihaoqi957 @ 2024-01-07 15:35:51

请教一下大佬们,第9个检查点报错,为什么啊?孩子真的看不出来哪里错了(>_<)

###P5707###

s, v = map(int, input().split())
time = s / v                        #单位为分钟
time += 10
if time % 1:
    pass
else:
    time = int(time) + 1

if time <= 60:
    minute = int(60 - time)
    hour = int(7)
    print(f"{hour:02d}:{minute:02d}")
elif 60 < time <= 480:
    hour_need = time // 60
    minute_need = time % 60
    hour = int(7 - hour_need)
    minute = int(60 - minute_need)
    print(f"{hour:02d}:{minute:02d}")
else:                               #出发时间为前一天的情况
    time = time - 480
    hour_need = time // 60
    minute_need = time % 60
    hour = int(23- hour_need)
    minute = int(60 - minute_need)
    print(f"{hour:02d}:{minute:02d}")

by tpzchonglqbshengyi @ 2024-01-10 00:32:23

if time > int(time): time = int(time) + 1

你的+1那部分判断不太对,像这样利用int取整和原先的判断的大小就可以,你原本的比如需要600分钟,判断后进入else后+1了 变成601分钟,实际上不需要+1,+1反而有误,所以通不过。


|