mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 5879_zsd201531107026.cpp
From http://blog.csdn.net/zsd201531107026/article/details/52564946
This commit is contained in:
parent
ef1992fa9e
commit
4f69664afa
33
HDOJ/5879_zsd201531107026.cpp
Normal file
33
HDOJ/5879_zsd201531107026.cpp
Normal file
|
@ -0,0 +1,33 @@
|
|||
#include<cstdio>
|
||||
#include<cstring>
|
||||
#include<algorithm>
|
||||
#include<cmath>
|
||||
using namespace std;
|
||||
|
||||
const int N = 1e6 + 5;
|
||||
|
||||
char a[N];
|
||||
double sum[N];
|
||||
|
||||
void yu()
|
||||
{
|
||||
for(int i = 1 ; i < N ; i++){
|
||||
sum[i] = sum[i - 1] + (double)1/i/i;
|
||||
}
|
||||
}
|
||||
int main()
|
||||
{
|
||||
yu();
|
||||
while(~scanf("%s",a)){
|
||||
int l = strlen(a);
|
||||
if(l >= 7) printf("%.5lf\n",sum[1000000]);
|
||||
else{
|
||||
int n = 0;
|
||||
for(int i = 0 ; i < l ; i++){
|
||||
n = n * 10 + a[i] - '0';
|
||||
}
|
||||
printf("%.5lf\n",sum[n]);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user