数学期望 概率递推

每一天的概率都是独立且相同的。可以先推出每天打i盘赢j盘的概率f[i][j]

f[i][j]=f[i-1][j]*(1-p) + f[i-1][j-1]*p

    输          赢

设此人打一天胜率不满足要求的概率为p

那么打一天的概率是1*p

打两天的概率是1*p*(p^2)

以此类推

----

题解待施工

学自http://www.cnblogs.com/neopenx/p/4282768.html

----

WA点:

  1、a和b用double存,可能引起了精度误差。

  2、输出没换行

 /*by SilverN*/
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<vector>
using namespace std;
const int mxn=;
int n;
double f[mxn][mxn];
int main(){
int T;int i,j,a,b,cas=;
scanf("%d",&T);
double p;
while(T--){
memset(f,,sizeof f);
scanf("%d/%d%d",&a,&b,&n);
p=(double)a/b;
f[][]=;
f[][]=;
for(i=;i<=n;i++){
f[i][]=f[i-][]*(-p);
for(j=;j*b<=i*a;j++){
f[i][j]=f[i-][j]*(-p)+f[i-][j-]*p;
}
}
double res=0.0;
for(i=;i<=n;i++)res+=f[n][i];//
double ans=/res;
printf("Case #%d: %d\n",++cas,(int)ans);
}
return ;
}

UVa11427 Expect the Expected的更多相关文章

  1. UVA11427 Expect the Expected 概率dp+全概率公式

    题目传送门 题意:小明每晚都玩游戏,每一盘赢的概率都是p,如果第一盘就赢了,那么就去睡觉,第二天继续玩:否则继续玩,玩到赢的比例大于p才去睡:如果一直玩了n盘还没完成,就再也不玩了:问他玩游戏天数的期 ...

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

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

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

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

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

    题目链接:uva 11427 - Expect the Expected 题目大意:你每天晚上都会玩纸牌,每天固定最多玩n盘,每盘胜利的概率为p,你是一个固执的人,每天一定要保证胜局的比例大于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 (期望)

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

  8. UVa 11427 (期望 DP) Expect the Expected

    设d(i, j)表示前i局每局获胜的比例均不超过p,且前i局共获胜j局的概率. d(i, j) = d(i-1, j) * (1-p) + d(i-1, j-1) * p 则只玩一天就就不再玩的概率Q ...

  9. Uva_11427 Expect the Expected

    题目链接 题意: 你玩纸牌, 如果当天晚上你赢的局数比例 大于 p, 就去睡觉, 第二天继续. 如果小于等于p, 就去睡觉, 并且以后都不玩了. 每晚最多玩n局, 每局赢的概率为p , 求玩的天数的期 ...

随机推荐

  1. Css3新特性总结之边框与背景(二)

    一.条纹背景 利用background为linear-gradient函数实现,linear-gradient取值如下: <angle>:角度,渐变的方向 to left right to ...

  2. angularjs 弹出框 $modal

    angularjs 弹出框 $modal 标签: angularjs 2015-11-04 09:50 8664人阅读 评论(1) 收藏 举报  分类: Angularjs(3)  $modal只有一 ...

  3. JQuery中隐藏/显示事件函数

    1.$("button").click(function(){ $("p").hide(); });2.如果您的网站包含许多页面,并且您希望您的 jQuery ...

  4. Markdown学习

    1. Markdown介绍 Markdown是一种轻量级的标记语言,它语法简单并且易读易用.Mardown文件通常以.md后缀结尾. 2. Markdown优点 纯文本格式,兼容性极强,可以用任意文本 ...

  5. Android面试题(一)

    1. 请描述一下Activity 生命周期. 答: 如下图所示.共有七个周期函数,按顺序分别是: onCreate(), onStart(), onRestart(), onResume(), onP ...

  6. WebServices:WSDL的结构分析

    WSDL(Web Services Description Language,Web服务描述语言)是为描述Web Services发布的XML格式.W3C组织没有批准1.1版的WSDL,但是2.0版本 ...

  7. 在DBeaver中phoenix查询报错:org.apache.phoenix.exception.PhoenixIOException: The system cannot find the path specified

    环境:Phoenix:4.4,win7系统 问题:Phoenix在查询hbase时,报"系统找不到指定路径". 解决: 请参见 https://distcp.quora.com/C ...

  8. 浅谈Virtual Machine Manager(SCVMM 2012) cluster 过载状态检测算法

    在我们使用scvmm2012的时候,经常会看到群集状态变成了这样 点开看属性后,我们发现是这样 . 发现了吗?Over-committed,如果翻译过来就是资源过载,或者说资源过量使用了,那么这个状态 ...

  9. NopCommerce 在Category 显示 Store List列表

    实现效果如下: 1.在前台Web的Category Menu显示 Store; 2.点击 Store 显示 Store List列表: 3.点击 列表Store 的 Company Name 进入该S ...

  10. JS--轻松设置获取表单数据

    接触过Angularjs的都知道,ng支持双向绑定,我们可以轻轻松松的通过ngModel将我们的值绑定到界面,当修改了值提交表单的时候不需要再重新通过ID去重新抓取输入框信息了.那对于我们开发前台网站 ...