| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 71192 | sh25_wangtaojie | 计算多项式的值 | C++ | 通过 | 0 MS | 268 KB | 525 | 2025-10-24 15:48:10 |
#include <iostream> #include <iomanip> #include <cmath> using namespace std; int main() { float x; int n; cin >> x >> n; float result; if (x == 1.0f) { // 当x=1时,所有项都是1,结果是n+1 result = n + 1; } else { // 使用等比数列求和公式 result = (pow(x, n + 1) - 1) / (x - 1); } // 设置输出精度为小数点后两位 cout << fixed << setprecision(2) << result << endl; return 0; }