题解 | 计算小球走过的路程和反弹高度
#include <iostream> #include <iomanip> using namespace std; int main() { // 下落的高度和落地的次数 double h; int n; cin >> h; cin >> n; // write your code here...... double sum_h = h; for (int i = 2; i <= n; i++){ h /= 2; sum_h += 2 * h; } cout << setprecision(1) << fixed << sum_h << " " << h/2 << endl; return 0; }