题意:某个人每天晚上都玩游戏,如果第一次就䊨了就高兴的去睡觉了,否则就继续直到赢的局数的比例严格大于 p,并且他每局获胜的概率也是 p,但是你最玩 n 局,但是如果比例一直超不过 p 的话,你将不高兴的去睡觉,并且以后再也不玩了,现在问你,平均情况下他玩几个晚上游戏. 析:先假设第一天晚上就不高兴的去睡觉的概率是 q,那么有期望公式可以得到 E = q + (1-q) * (E + 1),其中 E 就是数学期望,那么可以解得 E = 1/ q,所以答案就是 1 / q,这个公式是什么意思呢,把数…
题目链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=26&page=show_problem&problem=2422 题意:每天玩纸牌游戏,若胜的概率严格大于p时结束,第二天接着玩.每天最多玩n盘,n盘之后概率还是没有严格大于p,则结束而且以后再也不玩了.问玩多少天之后就不玩了. 思路: int a,b,n;double f[N][N]; int main()…
题目链接:uva 11427 - Expect the Expected 题目大意:你每天晚上都会玩纸牌,每天固定最多玩n盘,每盘胜利的概率为p,你是一个固执的人,每天一定要保证胜局的比例大于p才会结束游戏,若n局后仍没有,就会不开心,然后以后再也不完牌,问说你最多会玩多少个晚上. 解题思路:当j/i ≤ p时有dp(i-1,j) (1-p) + dp(i-1, j-1) p,其它dp(i,j) = 0.Q=∑d(n,i) 列出数学期望公式: EX=Q+2Q(1−Q)+3Q(1−Q)2+- s=…
UVA 11427 - Expect the Expected 题目链接 题意:玩一个游戏.赢的概率p,一个晚上能玩n盘,假设n盘都没赢到总赢的盘数比例大于等于p.以后都不再玩了,假设有到p就结束 思路:递推,dp[i][j]表示玩i盘.赢j盘的概率,那么一个晚上玩了n盘小于p的概率递推式为: dp(i,j)=dp(i−1,j)∗(1−p)+dp(i−1,j−1)∗p 总和为Q=dp(n,0)+dp(n,1)+...+dp(n,x)(x/n<p) 那么每一个晚上失败的概率Q就求出来了,那么平均玩…
Background If thou doest well, shalt thou not be accepted? and if thou doest not well, sin lieth at the door. And unto thee shall be his desire, and thou shalt rule over him.     And Cain talked with Abel his brother: and it came to pass, when they w…
Some mathematical background. This problem asks you to compute the expected value of a random variable. If you haven't seen those before, the simple denitions are as follows. A random variable is a variable that can have one of several values, each w…
题目链接 \(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\)为期望玩牌天数.有…
链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=35396 [思路] DP+概率 见白书. [代码] #include<cstdio> #include<cstring> using namespace std; +; int n,a,b; double f[N][N]; int main() { ; scanf("%d",&T); while(T--) { scanf(&qu…
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2422 每一天的情况是相互独立的 d[i][j] 表示这一天比了i次赢了j次还不能回去的概率 这样就可以 求出比了n次 仍然不能回去(垂头丧气回去,以后再也不玩了)的概率 Q 然后可以经过推导 最终期望为 1/Q 代码: #include<iostream> #include<…
King Arthur is an narcissist who intends to spare no coins to celebrate his coming K-th birthday. The luxurious celebration will start on his birthday and King Arthur decides to let fate tell when to stop it. Every day he will toss a coin which has p…