Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
128222 | 陈志轩 | 计算函数值 | C++ | 通过 | 100 | 0 MS | 256 KB | 251 | 2024-01-25 14:33:13 |
#include<bits/stdc++.h> #define int long long using namespace std; signed main(){ double x,n; cin>>x>>n; double ans = 0; for (int i = 1;i <= n;i++){ ans += 1.0 * pow(-1.0,(i - 1) & 1) * pow(x,i); } printf("%.2lf",ans); return 0; }