提交时间:2024-01-25 17:15:22
运行 ID: 128445
#include <bits/stdc++.h> using namespace std; int main(){ double x, n; cin >> x >> n; double tmp = 0; for ( int i = 1; i <= n; i++ ){ if ( i % 2 == 1 ){ tmp += pow(x, i); }else{ tmp -= pow(x, i); } } cout << fixed << setprecision(2) << tmp; return 0; }