UVA 11427 Expect the Expected(DP+概率)
链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=35396
【思路】
DP+概率
见白书。
【代码】
#include<cstdio>
#include<cstring>
using namespace std; const int N = +; int n,a,b;
double f[N][N]; int main() {
int T,kase=;
scanf("%d",&T);
while(T--) {
scanf("%d/%d%d",&a,&b,&n);
double p=(double)a/b;
memset(f,,sizeof(f));
f[][]=;
for(int i=;i<=n;i++)
for(int j=;j*b<=a*i;j++) {
f[i][j]=f[i-][j]*(-p);
if(j) f[i][j] += f[i-][j-]*p;
}
double Q=;
for(int j=;j*b<=a*n;j++) Q += f[n][j];
printf("Case #%d: %d\n",++kase,(int)(/Q));
}
return ;
}
UVA 11427 Expect the Expected(DP+概率)的更多相关文章
- 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 (数学期望 + 概率DP)
题意:某个人每天晚上都玩游戏,如果第一次就䊨了就高兴的去睡觉了,否则就继续直到赢的局数的比例严格大于 p,并且他每局获胜的概率也是 p,但是你最玩 n 局,但是如果比例一直超不过 p 的话,你将不高兴 ...
- 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.Expect the Expected(期望)
题目链接 \(Description\) https://blog.csdn.net/Yukizzz/article/details/52084528 \(Solution\) 首先每一天之间是独立的 ...
- 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局, ...
随机推荐
- IMPDP hangs, session wait “wait for unread message on broadcast channel”
昨晚有个朋友说加班在IMPDP数据, 在导入中途突然没有了进展,挂在那里不动了,impdp 窗口也没有报错, 一直等了1个多小时,说是impdp使用了parallel,怀疑是parallel参数出了问 ...
- Spring Security Encryption三种加密方式
Encryption One-way encryption 单项加密,客户端将要传递的值先加密(使用特定的加密方法),将原值和加密好的值传递过去,服务器端将原始数据也进行一次加密(两者加密 ...
- Python传参数最简单易懂的描述
关于,python的传参,很多人会搞得一头雾水,我也跟朋友讨论多次,最终通过实验,得到结论. 一.所有传递都是引用传递 二.在函数内使用[变量名]=,相当于定义啦一个局部变量 OK,一段简单的 ...
- gpload的简单实用
准备工作: 1.因为gpload是对gpfdist的封装,因此使用gpload之前必须开启gpfdist的服务,不然无法使用. gpfdist -d /home/admin -p 8181 -l /t ...
- Windows phone 之自定义控件(补充)
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x= ...
- sublime text 3 安装中文
本经验目前在Ubuntu14.04环境下,已有搜狗输入法 for Linux和Sublime Text 3的情况下安装成功. END 解决方法步骤2 1 保存下面的代码到文件sublime_imf ...
- apache2.4配置虚拟主机
step1 启用 httpd-vhosts.conf 找到E:/apache/Apache24/conf 中httpd.conf 文件,取消注释下面这句话 step2 在 httpd-vhosts.c ...
- Day20 Django之Model多对多、中间件、缓存、信号和分页
一.Form补充 class IndexForm(forms.Form): # c = [ # (1, 'CEO'), # (2, 'CTO') # ] # 静态字段,属于IndexForm类,即使数 ...
- Silverlight中在MVVM模式下对DatagridRow选择控件封装
在项目中,凡是涉及到表格的地方用的最多的控件,自然少不了DataGrid的身影,它明了的展示各种数据让人十分喜欢.现在要实现一个功能,使DataGrid具有全选和项选中的功能,如果在传统后台代码中完成 ...
- Sharepoint 问题集锦 - 配置
错误 在sharepoint designer中编辑List的表单的时候,提示soap:Server服务器无法处理请求. ---> 值不在预期的范围内. 解释: 这个是由于我在本地测试的时候,使 ...