图像法解题;
第一次落地前下落里程单算,弹起-下落为一组,1+4(弹起+下落);
第5次反弹是第5次下落的一半
#include <iostream> using namespace std; int main() { double height; cin >> height; double total = height, bounce = 0; double h = height / 2; for(int i = 0; i < 4; i++){ total += h * 2; bounce = h; h /= 2; } bounce = h; cout << total << endl; cout << bounce << endl; return 0; } // 64 位输出请用 printf("%lld")