您的位置:首页 > 其它

SGU 495. Kids and Prizes 期望

2014-10-02 13:29 381 查看
n个盒子 m个人轮流选 拿走盒子里的奖品 盒子再放回去 求得到奖品的期望

可以求没有被选到的奖品的期望 用n减去就是答案

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <math.h>
using namespace std;
int main()
{
    int n,m;
    while(scanf("%d%d",&n,&m)!=EOF)
    {
        double p=(double)(n-1)/n;
        double ans=n-n*pow(p,m);
        printf("%.10lf\n", ans);
    }
    return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: