BZOJ 1426 收集邮票

Posted on 2017-03-15 17:16  ziliuziliu  阅读(140)  评论(0编辑  收藏  举报

感谢http://hzwer.com/2860.html

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 10050
using namespace std;
int n;
double f[maxn],g[maxn];
int main()
{
    scanf("%d",&n);
    for (int i=n-1;i>=0;i--) f[i]=f[i+1]+(double)n/(n-i);
    for (int i=n-1;i>=0;i--)
    {
        double ret=1+(double)i/n*f[i]+(double)(n-i)/n*(g[i+1]+f[i+1]);
        g[i]=ret*n/(n-i);
    }
    printf("%.2lf\n",g[0]);
    return 0;
}