Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 293 Accepted Submission(s): 96
1 //2016.9.17 2 #include <iostream> 3 #include <cstdio> 4 5 using namespace std; 6 7 double sum[54000]; 8 9 int main() 10 { 11 int n; 12 double ans; 13 ans = 0; 14 sum[0] = 0; 15 for(int i = 1; i <= 53000; i++) 16 { 17 ans += (1.0/i)*(1.0/i); 18 sum[i] = ans; 19 } 20 string s; 21 while(cin>>s) 22 { 23 int len = s.length(); 24 n = 0; 25 for(int i = 0; i < len; i++) 26 { 27 n = n*10+s[i]-‘0‘; 28 if(n > 120000)break; 29 } 30 if(n >= 110291)ans = 1.64493; 31 else if(n >= 52447)ans = 1.64492; 32 else ans = sum[n]; 33 printf("%.5lf\n", ans); 34 } 35 36 return 0; 37 }
原文:http://www.cnblogs.com/Penn000/p/5879533.html