球从H高度(米)落下,反弹回B*H高度,其中B为反弹系数,0<;B<;1.当球从弹跳系数为B的表面上的高度H跌落时,计算球在静止前所经过的总距离。当高度小于1m时,球不会弹回
Input: H=5, B=0.5 Output: 12.5 Explanation : 5 + 2.5 + 2.5 + 1.25 + 1.25
我试过,
def bouncingBall(h, bounce, window):
if h != 0 and bounce > 0 and bounce < 1 and window < h:
count = 1
current = h*bounce
while current > window:
current *= bounce
count += 2
return h + 3 * current
else:
return -1
目前没有回答
相关问题 更多 >
编程相关推荐