题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
求小球落地5次后所经历的路程和第5次反弹的高度
http://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446
#include<stdio.h>
int main()
{
int h = 0;
double sum = 0;
int n = 5;
scanf("%d", &h);
double m = (double)h;
while(n)
{
sum += m + m/2;
m /= 2;
n--;
}
printf("%lf\n", sum-m);
printf("%lf\n", m);
}