题目链接

\(Description\)

https://blog.csdn.net/Yukizzz/article/details/52084528

\(Solution\)

首先每一天之间是独立的。

所以设\(f[i][j]\)为前\(i\)天赢了\(j\)局的概率,要满足当前获胜比例始终≤\(p\)。容易得出转移方程。

所以玩完\(n\)局之后获胜比例仍不超过\(p\)的概率为\(Q=\sum_{i=0}^{\frac in\leq p}f[n][i]\)。

设\(E\)为期望玩牌天数。有两种情况:

1.\(Q\)的概率不再玩了,期望为\(Q\times1\);

2.\(1-Q\)的概率第二天接着玩,期望为\((1-Q)\times(E+1)\)。

所以\(E=Q+(1-Q)\times(E+1)\),解得\(E=\frac 1Q\)。

有点迷,但好像也确实是这样。。

#include <cstdio>
#include <algorithm>
const int N=105; double f[N][N]; void Work(int T)
{
int a,b,n;
scanf("%d/%d%d",&a,&b,&n);
double p=1.0*a/b;
f[0][0]=1;
for(int i=1; i<=n; ++i)
{
f[i][0]=f[i-1][0]*(1-p);
for(int j=1; j<=i; ++j) f[i][j]=0;//!
for(int j=1; j*b<=i*a; ++j)
f[i][j]=f[i-1][j]*(1-p)+f[i-1][j-1]*p;
}
double q=0;
for(int i=0; i*b<=n*a; ++i) q+=f[n][i];
printf("Case #%d: %d\n",T,(int)(1.0/q));//直接.0lf是四舍五入...
} int main()
{
int T; scanf("%d",&T);
for(int i=1; i<=T; Work(i++));
return 0;
}

UVA.11427.Expect the Expected(期望)的更多相关文章

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

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

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

    题目链接:uva 11427 - Expect the Expected 题目大意:你每天晚上都会玩纸牌,每天固定最多玩n盘,每盘胜利的概率为p,你是一个固执的人,每天一定要保证胜局的比例大于p才会结 ...

  3. UVA 11427 Expect the Expected (期望)

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

  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. 「MYSQL」MYSQL中的int(11)到底代表什么意思?

    一.前言 在工作中经常要与mysql打交道,但是对mysql的各个字段类型一直都是一知半解,因此写本文总结记录一番. 二.简介 对于int类型的一些基础知识其实上图已经说的很明白了,在这里想讨论下常用 ...

  2. LaTeX符号和图片

    \documentclass{article} \usepackage{ctex} %中文处理 \begin{document} \section{空白符号} Are you wiser than o ...

  3. MySql数据库资料收集

    1.下载MySQL历史版本 https://downloads.mysql.com/archives/community/ https://downloads.mysql.com/archives/i ...

  4. CSS3 Day1 练习

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  5. 正则tips

    在啃Sizzle源码,被几个正则表达式给难住了,写了一下正则demo,记录一下 1,按照定义[]和(?:)里的内容不计入捕获组的数目 2,捕获组的计数顺序是,从大到小,同级从左到右 例如 var re ...

  6. [转载] PNG优化插件:TinyPNG for Photoshop CC

    http://www.im286.com/thread-14922316-1-1.html http://www.tinypng.com的PS插件版,优化.无损压缩PNG,支持批量处理,据说只支持Ph ...

  7. c# 防止sql注入对拼接sql脚本的各个参数处理

    调用方法:GameServerId = this.NoHtml(GameServerId);//GameServerId为一个拼接sql的参数 /// <summary> /// 过滤标记 ...

  8. Submatrix Sum

    Given an integer matrix, find a submatrix where the sum of numbers is zero. Your code should return ...

  9. oracle行转列

    wm_concat()函数 --创建表 create table test(id number,name varchar2(20)); --插入数据 insert into test values(1 ...

  10. FFT(快速傅里叶变换)摘要

    怎么说呢...这次的代码码风有点... 从这篇博客开始,我终于会用LATEX了!撒花 注:以下涉及多项式的n均表示多项式的次数 FFT用途 很简单,多项式相乘. FFT原理 如果暴力乘,复杂度是$O( ...