Run ID 作者 问题 语言 测评结果 Time Memory 代码长度 提交时间
112179 彭士宝 13自由落体 C++ Accepted 0 MS 268 KB 772 2025-03-08 16:31:13

Tests(1/1):


Code:

#include <iostream> #include <iomanip> // 用于设置小数精度 using namespace std; int main() { double initial_height = 100.0; double total_distance = initial_height; // 第一次下落的距离 double rebound_height = initial_height / 2.0; // 第一次反弹的高度 // 计算总距离 for (int i = 1; i < 11; i++) { total_distance += rebound_height * 2; // 每次反弹后上升和下落的距离 rebound_height /= 2.0; // 下一次反弹的高度 } // 计算第10次反弹的高度 double tenth_rebound_height = initial_height / (1 << 10); // 2的10次方 // 输出结果 cout << fixed << setprecision(6) << total_distance << " " << tenth_rebound_height << endl; return 0; }