diff --git a/HDOJ/5879_zsd201531107026.cpp b/HDOJ/5879_zsd201531107026.cpp new file mode 100644 index 0000000..181c5fd --- /dev/null +++ b/HDOJ/5879_zsd201531107026.cpp @@ -0,0 +1,33 @@ +#include +#include +#include +#include +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; +}