您的位置:首页 > 其它

SGU 495 Kids and Prizes

2015-07-31 11:00 267 查看
数学方法:

从每个箱子来考虑:m次选择以后,至少有一次被选中的概率为

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
const int maxn=110000;
double dp[maxn];
int main()
{
double n,m;
while (scanf("%lf %lf",&n,&m)==2)
{
double sum=1.0;
dp[1]=1;
for(int i=2;i<=m;i++)
{
dp[i]=(1-dp[i-1])*dp[i-1]+dp[i-1]*(dp[i-1]-1.0/n);
sum+=dp[i];
}
printf("%.9f\n",sum);
}
return 0;
}


代码君
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: