HDU5879 Cure
2016-09-21 08:44
363 查看
Cure
[b]Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1264 Accepted Submission(s): 424
[/b]
[align=left]Problem Description[/align]
Given an integer n,
we only want to know the sum of 1/k2
where k
from 1
to n.
[align=left]Input[/align]
There are multiple cases.
For each test case, there is a single line, containing a single positive integer
n.
The input file is at most 1M.
[align=left]Output[/align]
The required sum, rounded to the fifth digits after the decimal point.
[align=left]Sample Input[/align]
1
2
4
8
15
[align=left]Sample Output[/align]
1.00000
1.25000
1.42361
1.52742
1.58044
1000000后的结果都没变化了。
#include <bits/stdc++.h> using namespace std; #define maxn 1000010 #define ll long long int double sum[maxn]; char s[maxn]; int main() { ll i; char c; for(i = 1;i <= maxn;i++) sum[i] = sum[i-1]+1*1.0/(i*i); int len, all; while(~scanf("%s", s)){ len = strlen(s); all = 0; for(i = 0;i < len;i++){ all = all*10 + (s[i]-48); if(all>=maxn) break; } while((c=getchar())!='\n'){ if(all <= maxn) all = all*10 + (c-48); } if(all>=maxn) printf("%.5lf\n", sum[maxn]); else printf("%.5lf\n", sum[all]); } }
相关文章推荐
- hdu 5879 Cure
- HDU-5879-Cure
- HDU 5879 Cure(打表)qingdao网赛
- HDU 5879 Cure (2016 ACM/ICPC Asia Regional Qingdao Online 1002)
- HDU 5879 Cure
- HDU-5879 Cure(精度)(极限)
- HDU 5879 Cure(数学)
- HDU 5879 Cure
- hdu 5879 Cure 2016ACM/ICPC青岛赛区网络赛1002
- 【HDU 5879】Cure(暴力+优化)
- [HDU 5879] Cure (数学+打表)
- HDU 5879-Cure(1/n^2之和)
- HDU 5879---cure
- hdu 5879 Cure
- hdu 5879 Cure -ICPC网络赛青岛赛区
- hdu_5879_Cure(打表)
- hdu 5879 -Cure 暴力打表
- HDU 5879 Cure【数论】
- hdu 5879 Cure 打表
- HDU 5879 Cure .