ACMCoder 2009

ACMCoder2009 数列求和

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include <iostream>
#include <iomanip>
#include <math.h>

using namespace std;



int main(){

freopen("testcase.in", "r", stdin);
freopen("testcase.out", "w", stdout);
double n,m;
while (cin>>n>>m&&n>=0&&m>=0) {
m-=1;
double sum = n;
while (m--) {
n = sqrt((double)n);
sum += n;
}
cout<<setiosflags(ios::fixed)<<setprecision(2)<<(double)sum<<endl;
}
fclose(stdin);
fclose(stdout);

return 0;
}