Python 只有50分是为什么啊?

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

MISK_1969 @ 2024-01-03 15:35:58

s,v=map(int,input().split(" ")) time=s/v+10 hour=time//60 minute=time%60 H=8-hour M=60-minute if M >0: H=H-1 else: H=H M=int(M) H=int(H) template='{:0>2}:{:}' context=template.format(H,M) print(context)


by exlysha @ 2024-01-16 08:49:20

分钟值也有可能是个位数……
这题真的很坑人,看着简单但是有好多易错点
附上ac的python3代码:
import math
s=input('')
s=s.split() t=math.ceil(eval(s[0])/eval(s[1]))+10
sh=8-math.ceil(t/60)
f=60-t%60
if sh>=0:
if f>=10:
print("0{}:{}".format(sh,f))
else:
print("0{}:0{}".format(sh,f))
else:
sh+=24
if sh>=10:
if f>=10:
print("{}:{}".format(sh,f))
else:
print("{}:0{}".format(sh,f))
else:
if f>=10:
print("0{}:{}".format(sh,f))
else:
print("0{}:0{}".format(sh,f))


|