题目链接: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. Leetcode#117 Populating Next Right Pointers in Each Node II

    原题地址 二叉树的层次遍历. 对于每一层,依次把各节点连起来即可. 代码: void connect(TreeLinkNode *root) { if (!root) return; queue< ...

  2. JAVA swing中JPanel如何实现分组框的效果以及设置边框颜色 分类: Java Game 2014-08-16 12:21 198人阅读 评论(0) 收藏

    代码如下: import java.awt.FlowLayout; import java.awt.Frame; import java.awt.GridLayout; import javax.sw ...

  3. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets(611,5): error MSB

    project options, linker, manifest, Generate Manifest-> NO. 项目->属性->链接器->清单文件->生成清单  改 ...

  4. .NET设计模式(18):迭代器模式(Iterator Pattern)(转)

    概述 在面向对象的软件设计中,我们经常会遇到一类集合对象,这类集合对象的内部结构可能有着各种各样的实现,但是归结起来,无非有两点是需要我们去关心的:一是集合内部的数据存储结构,二是遍历集合内部的数据. ...

  5. 用include来处理模板的问题

    /** * 测试方法 */ protected function getHtml() { $tpl = $this->pageletDir.$this->plTemplate; $html ...

  6. Ruby中的语句中断和返回

    李哲 - APRIL 28, 2015 return,break,next 这几个关键字的使用都涉及到跳出作用域的问题,而他们的不同 则在于不同的关键字跳出去的目的作用域的不同,因为有代码块则导致有一 ...

  7. MVC中 ViewBag、ViewData和TempData区别

    MVC3中 ViewBag.ViewData和TempData的使用和区别 public dynamic ViewBag { get; } public ViewDataDictionary View ...

  8. GridControl Find/Clear 添加图标

    public static void ControlFind(GridControl grid) { FindControl fControl = null; foreach (Control ite ...

  9. C#中String跟string的“区别”

    string是c#中的类,String是.net Framework的类(在C# IDE中不会显示蓝色) C# string映射为.net Framework的String 如果用string,编译器 ...

  10. 很不错的文章---【问底】徐汉彬:亿级Web系统搭建——单机到分布式集群

    [导读]徐汉彬曾在阿里巴巴和腾讯从事4年多的技术研发工作,负责过日请求量过亿的Web系统升级与重构,目前在小满科技创业,从事SaaS服务技术建设. 大规模流量的网站架构,从来都是慢慢“成长”而来.而这 ...