题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
求小球落地5次后所经历的路程和第5次反弹的高度
https://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446
#include <iostream>
using namespace std;
int main() {
double a;
int times = 5;
double totalDistance = 0.0;
while (cin >> a) { // 注意 while 处理多个 case
while(times > 0)
{
totalDistance += a * 1.5;
a /= 2;
--times;
}
cout << totalDistance - a << endl;
cout << a;
}
}
// 64 位输出请用 printf("%lld")


查看10道真题和解析