【问题描述】
有一弹性小球从高度为h米处落到地面,每次弹起高度为原下落高度的3/4。当小球下落弹起n次后,求小球运动过的距离。
【输入形式】
(1)下落原始高度h=
(2)小球弹起次数n=
【输出形式】
(1)小球每次下落、弹起高度
(2)小球弹起次数和经过距离为
【样例输入】
下落原始高度h=100
小球弹起次数n=2
【样例输出】
100 75.0
75.0 56.25
小球弹起2次,经过距离为306.25米
【样例说明】
【评分标准】
h = eval(input("下落原始高度h="))
n = int(input("小球弹起次数n="))
total_distance = h
previous_height = h
for i in range(n):
current_height = previous_height * 3 / 4
total_distance += current_height * 2
print(previous_height,current_height)
previous_height = current_height
print(f"\n小球弹起{n}次,经过距离为{total_distance-current_height}米")