Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
127472 | 罗嘉为 | 计算函数值 | C++ | 通过 | 100 | 0 MS | 260 KB | 279 | 2024-01-25 09:13:32 |
#include <bits/stdc++.h> using namespace std; int main(){ int x, n; cin >> x >> n; double ans; for(int i = 1; i <= n; i++){ if(i % 2 != 0){ ans += pow(x, i); } else { ans -= pow(x, i); } } cout << fixed << setprecision(2) << ans; return 0; }