输入
一行,两个整数,第一个整数为墙高,第二个整数为每分钟向上爬的距离,中间用空格隔开
输出
一个整数,为小虫爬上墙的时间,不足1分钟,按1分钟计算
x,y=map(int,input().split())
count = 0
height = 0
while True:
count+=1
height+=y
if height<x:
count+=1
height-=1
else:
print(count)
break
有帮助望采纳
不用循环,一个整除和取余就可以。
height, length = map(int, input().split())
res = divmod(height - 1, length - 1)
print(2 * res[0] + bool(res[1]))
如果有用,请点击采纳谢谢!
这不久一个循环,