1 2 3 4 0
1.00 3.00 5.67 8.83
#include<iostream> #include<cstring> using namespace std; int main() { double a[50005],s[50005]; a[1]=s[1]=1; for(int i=2;i<=50000;i++) { a[i]=a[i-1]+(double)1/i; s[i]=a[i]*2+s[i-1]-1; } int n; while(cin>>n && n) { printf("%.2lf\n",s[n]); } return 0; }
原文:http://blog.csdn.net/hyccfy/article/details/38259077