题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
求小球落地5次后所经历的路程和第5次反弹的高度
http://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446
等比数列
def getAns(ini, times):
heights = [ini*(0.5**n) for n in range(times + 1)]
sums = [0] * (times + 1)
sums[0] = ini
for i in range(1,times):
sums[i] = sums[i-1] + 2*heights[i]
print(sums[times - 1])
print(heights[times])
while True:
try:
ini = int(input())
getAns(ini, 5)
except:
break