题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=26&page=show_problem&problem=2422

题意:每天玩纸牌游戏,若胜的概率严格大于p时结束,第二天接着玩。每天最多玩n盘,n盘之后概率还是没有严格大于p,则结束而且以后再也不玩了。问玩多少天之后就不玩了。

思路:

int a,b,n;
double f[N][N];

int main()
{
    int num=0;
    rush()
    {
        scanf("%d/%d %d",&a,&b,&n);
        double p=1.0*a/b;
        clr(f,0);
        f[0][0]=1;
        int i,j;
        FOR1(i,n) for(j=0;j*b<=a*i;j++)
        {
            f[i][j]=f[i-1][j]*(1-p);
            if(j) f[i][j]+=f[i-1][j-1]*p;
        }
        double ans=0;
        for(i=0;i*b<=a*n;i++) ans+=f[n][i];
        printf("Case #%d: %d\n",++num,(int)(1/ans));
    }
}

UVA 11427 Expect the Expected (期望)的更多相关文章

  1. UVA.11427.Expect the Expected(期望)

    题目链接 \(Description\) https://blog.csdn.net/Yukizzz/article/details/52084528 \(Solution\) 首先每一天之间是独立的 ...

  2. UVA 11427 - Expect the Expected(概率递归预期)

    UVA 11427 - Expect the Expected 题目链接 题意:玩一个游戏.赢的概率p,一个晚上能玩n盘,假设n盘都没赢到总赢的盘数比例大于等于p.以后都不再玩了,假设有到p就结束 思 ...

  3. uva 11427 - Expect the Expected(概率)

    题目链接:uva 11427 - Expect the Expected 题目大意:你每天晚上都会玩纸牌,每天固定最多玩n盘,每盘胜利的概率为p,你是一个固执的人,每天一定要保证胜局的比例大于p才会结 ...

  4. UVa 11427 Expect the Expected (数学期望 + 概率DP)

    题意:某个人每天晚上都玩游戏,如果第一次就䊨了就高兴的去睡觉了,否则就继续直到赢的局数的比例严格大于 p,并且他每局获胜的概率也是 p,但是你最玩 n 局,但是如果比例一直超不过 p 的话,你将不高兴 ...

  5. UVA - 11427 Expect the Expected (概率dp)

    Some mathematical background. This problem asks you to compute the expected value of a random variab ...

  6. UVa 11427 - Expect the Expected

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  7. UVA 11427 Expect the Expected(DP+概率)

    链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=35396 [思路] DP+概率 见白书. [代码] #include&l ...

  8. 11427 - Expect the Expected(概率期望)

    11427 - Expect the Expected Some mathematical background. This problem asks you to compute the expec ...

  9. UVA 11427 (概率DP+期望)

    题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=35396 题目大意:每晚打游戏.每晚中,赢一局概率p,最多玩n局, ...

随机推荐

  1. 【BZOJ】【2765】【JLOI2010】铁人双项比赛

    计算几何/半平面交 本来我是想去写POJ 1755的,然后想起了这道跟它很像的题,但应该是弱化版,所以就先写了这个…… 我们可以发现每个人的总用时,与k是呈一次函数关系的:$time_i=\frac{ ...

  2. Matlab验证公式取值范围

    一.问题来源 t = 2xy/(x+y);融合相似度和信任度,我需要验证值域是不是[0,1]: 二.求解 clear all; clc; %linspace(0:1,0.1)这样是错的,第三个参数是段 ...

  3. 2014ACM/ICPC亚洲区广州站 北大命题

    http://acm.hdu.edu.cn/showproblem.php?pid=5131 现场赛第一个题,水题.题意:给水浒英雄排序,按照杀人数大到小,相同按照名字字典序小到大.输出.然后对每个查 ...

  4. 【bzoj1085】[SCOI2005]骑士精神

    1085: [SCOI2005]骑士精神 Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 1757  Solved: 961[Submit][Statu ...

  5. NGP处理包

    NGP处理部分(主要就是这个RunOnce函数,客户单肯定是开个线程取调用这个RunOnce的) void NGP::RunOnce() { m_spTimerFac->driveTimer() ...

  6. remoting技术

    转: http://www.cnblogs.com/rickie/category/5082.html

  7. easyui 页签

    昨天开始搭后台框架,到晚上的时候遇到了一个现在觉得挺可笑但是当时一直很纠结很纠结的问题,这个问题刚刚解决出来,把它拿出来说说,让自己长点儿记性,希望大家不要犯我这个错误啊 在backstage.jsp ...

  8. [大牛翻译系列]Hadoop(5)MapReduce 排序:次排序(Secondary sort)

    4.2 排序(SORT) 在MapReduce中,排序的目的有两个: MapReduce可以通过排序将Map输出的键分组.然后每组键调用一次reduce. 在某些需要排序的特定场景中,用户可以将作业( ...

  9. POJ 3982 序列(JAVA,简单,大数)

    题目 //在主类中 main 方法必须是 public static void 的,在 main 中调用非static类时会有警告信息, //可以先建立对象,然后通过对象调用方法: import ja ...

  10. Wamp Mysql错误消息 语言设置

    Wamp Mysql错误消息 语言设置 http://my.oschina.net/wandershi/blog/264347 打开my.ini   找到 [wampmysqld] port = 33 ...