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