标签:
题解:考虑期望的线性特征,于是我们可以知道:
#include<iostream> #include<cstring> #include<cstdio> #include<cmath> #include<algorithm> #define N 10005 using namespace std; int n; double f[N],g[N]; int main() { scanf("%d",&n); f[n]=g[n]=0; for (int i=n-1; i>=0; i--) { f[i]=f[i+1]+1.0*n/(n-i); g[i]=g[i+1]+2.0*f[i+1]+2.0*i/(n-i)*f[i]+1.0*n/(n-i); } printf("%0.2lf",(f[0]+g[0])/2); return 0; }
标签:
原文地址:http://www.cnblogs.com/HQHQ/p/5793681.html