标签:
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 0 Accepted Submission(s): 0
1 #include <iostream> 2 #include<cstdio> 3 #include<cmath> 4 #include<cstdlib> 5 #include<cstring> 6 using namespace std; 7 double a[1000005]; 8 char ch[1000005]; 9 int n; 10 int main() 11 { 12 13 for(int i=1000000;i>=1;i--) 14 a[i]=a[i+1]+1.0/pow((double)i,2.0); 15 16 while(~scanf("%s",&ch)) 17 { 18 int len=strlen(ch); 19 int n=0; 20 for(int i=0;i<len;i++) {n=n*10+ch[i]-‘0‘; if (n>1000000) break;} 21 22 if(n>=1000000) printf("%.5lf\n",a[1]); 23 else printf("%.5lf\n",a[1]-a[n+1]); 24 } 25 return 0; 26 }
2016 ACM/ICPC Asia Regional Qingdao Online 1002 Cure
标签:
原文地址:http://www.cnblogs.com/Annetree/p/5879850.html