70分求助python写的

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

MRZ000 @ 2024-11-22 21:04:48

mport math

s,v = map(int,input().split())
t = math.ceil(s/v) + 10
n = t // 60
m = t % 60
hour = 7
minute = 60
if t >= 60:
    hour -= n
    minute -= m
    if m == 0:
        hour += 1
        print("0%d:00"%hour)
    elif m <= 50:
        print("0%d:%d"%(hour,minute))
    elif m > 50:
        print("0%d:0%d"%(hour,minute))

else:
    minute -= m
    if m <= 50:
        print("0%d:%d"%(hour,minute))

    elif m > 50:
        print("0%d:0%d"%(hour,minute))

by yuanyuan_919 @ 2024-11-29 15:12:40

其实可以采取一点简单的思路

import math
s,v=map(int,input().rstrip().split())
time=math.ceil(s/v)+10
HH=(480-time)//60
MM=(480-time)%60
if HH<0:
    HH+=24
print(f"{HH:02}:{MM:02}")

|