Problem description
The sequence is defined as follows:
The first item of the series is N, and the subsequent items are the square root of the previous item, and the sum of the first m items of the series is obtained.
Input
There are multiple groups of input data. Each group occupies one row and consists of two integers n (n <10000) and M (M <1000). The meanings of N and m are as described above.
Output
For each group of input data, the sum of the output columns, each test instance occupies a row, requires that the precision be kept with 2 decimal places.
Sample Input
81 4
2 2
Sample output
94.73
3.41
1 #include <stdio.h> 2 #include <math.h> 3 4 int main(){ 5 double a; 6 int b; 7 int i; 8 double result; 9 10 11 while((scanf("%lf%d",&a,&b))!=EOF){12 result=0;13 14 for(i=0;i<b;i++){15 result+=a;16 a=sqrt(a);17 }18 19 printf("%.2lf\n",result);20 }21 22 return 0;23 }
Returns the sum of the number of columns.