7. 【竞赛】小球落弹运动

【问题描述】

有一弹性小球从高度为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}米")
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值