UVA 11427 Expect the Expected (期望)
题意:每天玩纸牌游戏,若胜的概率严格大于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 (期望)的更多相关文章
- UVA.11427.Expect the Expected(期望)
题目链接 \(Description\) https://blog.csdn.net/Yukizzz/article/details/52084528 \(Solution\) 首先每一天之间是独立的 ...
- UVA 11427 - Expect the Expected(概率递归预期)
UVA 11427 - Expect the Expected 题目链接 题意:玩一个游戏.赢的概率p,一个晚上能玩n盘,假设n盘都没赢到总赢的盘数比例大于等于p.以后都不再玩了,假设有到p就结束 思 ...
- uva 11427 - Expect the Expected(概率)
题目链接:uva 11427 - Expect the Expected 题目大意:你每天晚上都会玩纸牌,每天固定最多玩n盘,每盘胜利的概率为p,你是一个固执的人,每天一定要保证胜局的比例大于p才会结 ...
- UVa 11427 Expect the Expected (数学期望 + 概率DP)
题意:某个人每天晚上都玩游戏,如果第一次就䊨了就高兴的去睡觉了,否则就继续直到赢的局数的比例严格大于 p,并且他每局获胜的概率也是 p,但是你最玩 n 局,但是如果比例一直超不过 p 的话,你将不高兴 ...
- UVA - 11427 Expect the Expected (概率dp)
Some mathematical background. This problem asks you to compute the expected value of a random variab ...
- UVa 11427 - Expect the Expected
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
- UVA 11427 Expect the Expected(DP+概率)
链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=35396 [思路] DP+概率 见白书. [代码] #include&l ...
- 11427 - Expect the Expected(概率期望)
11427 - Expect the Expected Some mathematical background. This problem asks you to compute the expec ...
- UVA 11427 (概率DP+期望)
题目链接: http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=35396 题目大意:每晚打游戏.每晚中,赢一局概率p,最多玩n局, ...
随机推荐
- spring framework项目源码github托管地址
方法一:直接下载,github托管地址:http://repo.spring.io/simple/libs-release-local/org/springframework/spring/ 方法二: ...
- 委托、事件和Lambda
一.委托 delegate1.在.Net平台下,委托类型用来定义和响应应用程序中的回调.事实上,.Net委托类型是一个类型安全的对象,指向可以以后调用的其他方法,.Net委托是内置支持多路广播和异步方 ...
- BackgroundWorker
Constants.Worker = new BackgroundWorker(); Constants.Worker.WorkerSupportsCancellation = true; Const ...
- 【转载】让c++ 函数返回一个数组
在c++中是不允许数组作为函数的返回值的 int [] someFunction( ); //ILLEGAL 要想实现函数返回一个数组,那返回对应数组里面类型的指针 you must return a ...
- spring mvc注解@RequestParam
在spring mvc 的使用过程中 获取 页面传来的参数的时候,我平时都习惯 @RequestParam String name,突然有一天我发现 直接在方法参数后面写 String name , ...
- Android Environment FAQ (Frequently Asked Question)
1.how to find out the Eclipse Version From Eclipse Menu Help ----> About Eclipse It displayed as ...
- 函数式 CSS (FCSS)
在Wealthfront我们是一个函数式编程的超级粉丝.强调不变性和函数式风格意味着更少的“意外”(surprises),因为副作用是有限的或不存在的.我们能将独立的组件迅速构建出大型系统,通过组合的 ...
- lof基金
lof基金 编辑 LOF基金,英文全称是"Listed Open-Ended Fund",汉语称为"上市型开放式基金".也就是上市型开放式基金发行结束后,投资者 ...
- POJ 2105
#include <iostream> #include <cmath> #include <string> using namespace std; int ma ...
- .Net知识点总结(一)
1.文件上传:Jquery.uploadify 它依赖于flash 舍去起上传 功能 改用SWFupload 他是第三方的插件 2.验证码激活的时候,邮箱开始是写死的,但是为了以后更改邮箱 ...