http://www.cnblogs.com/rainydays/archive/2013/01/16/2862235.html
看样例的答案
#include<stdio.h> #include<string.h> #include<algorithm> #include<math.h> using namespace std; typedef long long ll; #define MAXN 100010 double z[MAXN]; int main() { z[1]=0.5; for(int i=2;i<MAXN;i++) z[i]=z[i-1]+1.0/(i*2); int n; printf("# Cards Overhang "); while(scanf("%d",&n)!=EOF) { printf("%5d%10.3lf ",n,z[n]); } return 0; }