From 4f69664afa9d63caafe5d177db0f88ae5145bc71 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Sat, 17 Sep 2016 22:05:30 +0800 Subject: [PATCH] Create 5879_zsd201531107026.cpp From http://blog.csdn.net/zsd201531107026/article/details/52564946 --- HDOJ/5879_zsd201531107026.cpp | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 HDOJ/5879_zsd201531107026.cpp 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; +}