Time Limit: 2000/1000 MS (java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 79327 Accepted Submission(s): 48185
數列的定義如下: 數列的第一項為n,以后各項為前一項的平方根,求數列的前m項的和。
Input
輸入數據有多組,每組占一行,由兩個整數n(n<10000)和m(m<1000)組成,n和m的含義如前所述。
Output
對于每組輸入數據,輸出該數列的和,每個測試實例占一行,要求精度保留2位小數。
Sample Input
81 4 2 2
Sample Output
94.73 3.41
#include <stdio.h>#include<math.h>/* run this program using the console pauser or add your own getch, system("pause") or input loop */int main(int argc, char *argv[]) { int n,m; double sum,s; while(scanf("%d%d",&n,&m)!=EOF) { sum=0.; s=n; for(;m>0;m--) { sum+=s; s=sqrt(s); } printf("%.2lf/n",sum); } return 0;}新聞熱點
疑難解答