标签:杭电 lse mit while pre col output mis double
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 108816 Accepted Submission(s): 61288
1 #include<iostream> 2 #include<cstdio> 3 using namespace std; 4 int main() 5 { 6 int m,n,i; 7 double num; 8 cin>>m; 9 while(m--) 10 { 11 double sum=0; 12 cin>>n; 13 for(i=1;i<=n;i++) 14 { 15 num=i; 16 if(i%2==0)sum-=1/num; 17 //num=(i%2==0)?(-i):i; 18 else sum+=1/num; 19 } 20 printf("%.2lf\n",sum); 21 } 22 return 0; 23 }
标签:杭电 lse mit while pre col output mis double
原文地址:https://www.cnblogs.com/lightice/p/10261127.html