题解 | #求小球落地5次后所经历的路程和第5次反弹的高度#
求小球落地5次后所经历的路程和第5次反弹的高度
https://www.nowcoder.com/practice/2f6f9339d151410583459847ecc98446
#include <iostream>
#include <iomanip>
using namespace std;
int main(int argc, char* argv[]){
int n;
cin >> n;
double length = double(n);
double height = double(n);
for(int i = 1; i <= 5; ++i){
height /= 2;
length += 2*height;
}
length -= 2*height;
cout << setprecision(6) << length << endl;
cout << setprecision(6) << height << endl;
return 0;
}