UVa11427 Expect the Expected
数学期望 概率递推
每一天的概率都是独立且相同的。可以先推出每天打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的更多相关文章
- UVA11427 Expect the Expected 概率dp+全概率公式
题目传送门 题意:小明每晚都玩游戏,每一盘赢的概率都是p,如果第一盘就赢了,那么就去睡觉,第二天继续玩:否则继续玩,玩到赢的比例大于p才去睡:如果一直玩了n盘还没完成,就再也不玩了:问他玩游戏天数的期 ...
- 11427 - Expect the Expected(概率期望)
11427 - Expect the Expected Some mathematical background. This problem asks you to compute the expec ...
- 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)
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 (期望)
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=26&pa ...
- 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 ...
- Uva_11427 Expect the Expected
题目链接 题意: 你玩纸牌, 如果当天晚上你赢的局数比例 大于 p, 就去睡觉, 第二天继续. 如果小于等于p, 就去睡觉, 并且以后都不玩了. 每晚最多玩n局, 每局赢的概率为p , 求玩的天数的期 ...
随机推荐
- sed的应用
h3 { color: rgb(255, 255, 255); background-color: rgb(30,144,255); padding: 3px; margin: 10px 0px } ...
- FineReport制作可动态展开的组织递归树报表
先看看效果: 报表软件:FineReport 1.分析-与正常查询的对比 如果不做这种树状结构展开的报表的话,正常的SQL应该是这样写的,以单据表为例,假设单据的机构为分公司,经营部 select 分 ...
- iOS NSDate等时间类的使用
一.NSDate NSDate对象用来表示一个具体的时间点. NSDate是一个类簇,我们所使用的NSDate对象,都是NSDate的私有子类的实体. NSDate存储的是GMT时间,使用的时候会根据 ...
- Oracle Sales Cloud:报告和分析(BIEE)小细节1——创建双提示并建立关联(例如,部门和子部门提示)
Oracle Sales Cloud(Oracle 销售云)是一套基于Oracle云端的客户商机管理系统,通过提供丰富的功能来帮助提高销售效率,更好地去了解客户,发现和追踪商机,为最终的销售成交 (d ...
- 处理程序“ExtensionlessUrlHandler-Integrated-4.0”在其模块列表中有一个错误模块“ManagedPipelineHandler”
新服务器安装完开发环境后,还需要注册framework4.0到IIS.不然会报错: HTTP 错误 500.21 - Internal Server Error 处理程序“Extensionles ...
- [Hadoop in Action] 第2章 初识Hadoop
Hadoop的结构组成 安装Hadoop及其3种工作模式:单机.伪分布和全分布 用于监控Hadoop安装的Web工具 1.Hadoop的构造模块 (1)NameNode(名字节点) ...
- [笔记]ubuntu安装flashplayer
为firefox安装: 下载tar.gz压缩包:http://get.adobe.com/cn/flashplayer/ 解压:tar -xvxf install_flash_player_11_li ...
- Unity中使用Attribute
Attribute是c#的语言特性 msdn说明如下: The Attribute class associates predefined system information or user-def ...
- codevs 1576 最长上升子序列的线段树优化
题目:codevs 1576 最长严格上升子序列 链接:http://codevs.cn/problem/1576/ 优化的地方是 1到i-1 中最大的 f[j]值,并且A[j]<A[i] .根 ...
- Linux 管道的实现模型
//管道的实现 //当前目录下实现命令"ls | wc -w" #include <stdio.h> #include <stdlib.h> #includ ...