SPOJ - FAVDICE 简单期望
dp[0]=0;
// rep(i,1,n) dp[i]=(double)(n-i)/n*dp[i-1]+1+(double)(i)/n*dp[i];
// (n-i)/n dp[i]= n-i / n * dp[i-1] +1 => dp[i]=dp[i-1]+n/n-i
rep(i,1,n-1) dp[i]=dp[i-1]+(double)n/(n-i);
ans为dp[n-1]+1
dp[0]=0;
// rep(i,1,n) dp[i]=(double)(n-i)/n*dp[i-1]+1+(double)(i)/n*dp[i];
// (n-i)/n dp[i]= n-i / n * dp[i-1] +1 => dp[i]=dp[i-1]+n/n-i
rep(i,1,n-1) dp[i]=dp[i-1]+(double)n/(n-i);
ans为dp[n-1]+1