题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
求小球落地5次后所经历的路程和第5次反弹的高度
http://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446
Python 实现
height = int(input())
total_distance = 0
rebound_height = 0
for i in range(5):
if i != 0:
total_distance += 2 * height
else:
total_distance += height
height = height / 2
rebound_height = height
print(total_distance)
print(rebound_height)