题目传送门 题意:小明每晚都玩游戏,每一盘赢的概率都是p,如果第一盘就赢了,那么就去睡觉,第二天继续玩:否则继续玩,玩到赢的比例大于p才去睡:如果一直玩了n盘还没完成,就再也不玩了:问他玩游戏天数的期望: 思路:由于每次玩游戏,每天玩游戏都是独立重复试验,所以可以考虑一天玩游戏,玩不到p的概率(p都玩不到?). 设$dp[i][j]$表示玩了i次游戏,获胜j次,并且过程中期望都不会超过p的概率. 则显然有:$dp[i][j]=dp[i-1][j]*(1-p)+dp[i-1][j-1]*p$. 需…
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…
11427 - Expect the Expected Some mathematical background. This problem asks you to compute the expected value of a randomvariable. If you haven’t seen those before, the simple definitions are as follows. A random variable is avariable that can have o…
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就求出来了,那么平均玩…
题目链接: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=…
链接: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…
数学期望 概率递推 每一天的概率都是独立且相同的.可以先推出每天打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.输出没换行 /…
题意:某个人每天晚上都玩游戏,如果第一次就䊨了就高兴的去睡觉了,否则就继续直到赢的局数的比例严格大于 p,并且他每局获胜的概率也是 p,但是你最玩 n 局,但是如果比例一直超不过 p 的话,你将不高兴的去睡觉,并且以后再也不玩了,现在问你,平均情况下他玩几个晚上游戏. 析:先假设第一天晚上就不高兴的去睡觉的概率是 q,那么有期望公式可以得到 E = q + (1-q) * (E + 1),其中 E 就是数学期望,那么可以解得 E = 1/ q,所以答案就是 1 / q,这个公式是什么意思呢,把数…
http://acm.split.hdu.edu.cn/showproblem.php?pid=4405 Aeroplane chess Problem Description   Hzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz starts at grid 0. For each step he throws a dice(a dice have six…
Recently poet Mr. po encountered a serious problem, rumor said some of his early poems are written by others. This brought a lot of trouble to Mr. po, so one day he went to his best friend MasterO for help. MasterO handed over a small wooden box with…
Aeroplane chess Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1503    Accepted Submission(s): 1025 Problem Description Hzz loves aeroplane chess very much. The chess map contains N+1 grids la…
The number of steps Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描写叙述 Mary stands in a strange maze, the maze looks like a triangle(the first layer have one room,the second layer have two rooms,the third layer have three rooms -). Now she…
转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud The number of steps Time Limit: 1 Sec  Memory Limit: 128 M Description Mary stands in a strange maze, the maze looks like a triangle(the first layer have one room,the second layer have two ro…
LOOPS Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others) Total Submission(s): 1864    Accepted Submission(s): 732 Problem Description Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). Homura wants to help h…
Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4512   Accepted: 1988 Description Organizing a programming contest is not an easy job. To avoid making the problems too difficult, the organizer usually exp…
Card Collector Problem Description In your childhood, do you crazy for collecting the beautiful cards in the snacks? They said that, for example, if you collect all the 108 people in the famous novel Water Margin, you will win an amazing award.  As a…
Problem   Codeforces #548 (Div2) - D.Steps to One Time Limit: 2000 mSec Problem Description Input The first and only line contains a single integer mm (1≤m≤100000,1≤m≤100000). Output Print a single integer — the expected length of the array aa writte…
题目链接:https://cn.vjudge.net/problem/LightOJ-1030 You are in a cave, a long cave! The cave can be represented by a 1 x N grid. Each cell of the cave can contain any amount of gold. Initially you are in position 1. Now each turn you throw a perfect 6 si…
LOOPS Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others) Total Submission(s): 4636    Accepted Submission(s): 1862 Problem Description Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). Homura wants to help…
Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 8903   Accepted: 3772 Description Organizing a programming contest is not an easy job. To avoid making the problems too difficult, the organizer usually exp…
D. Broken robot time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You received as a gift a very clever robot walking on a rectangular board. Unfortunately, you understood that it is broken a…
Card Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 3407    Accepted Submission(s): 1665Special Judge Problem Description In your childhood, do you crazy for collecting the beautiful…
Hzz loves aeroplane chess very much. The chess map contains N+1 grids labeled from 0 to N. Hzz starts at grid 0. For each step he throws a dice(a dice have six faces with equal probability to face up and the numbers on the faces are 1,2,3,4,5,6). Whe…
LOOPS Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 125536/65536 K (Java/Others)Total Submission(s): 8453    Accepted Submission(s): 3397 Problem Description Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). Homura wants to help h…
题意:n支队伍两两进行比赛,求最有可能获得冠军的队伍. 解题关键:概率dp,转移方程:$dp[i][j] +  = dp[i][j]*dp[i][k]*p[j][k]$表示第$i$回合$j$获胜的概率,原理为全概率公式. 如何判断相邻,通过位运算. 概率dp的过程就像是模拟的过程 复杂度:$O(n{2^n}{2^n})$ #include<cstdio> #include<cstring> #include<algorithm> #include<cstdlib&…
Check the difficulty of problems Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 4403   Accepted: 1941 Description Organizing a programming contest is not an easy job. To avoid making the problems too difficult, the organizer usually exp…
题目链接:Coins Description Alice and Bob are playing a simple game. They line up a row of nn identical coins, all with the heads facing down onto the table and the tails upward. For exactly mm times they select any kk of the coins and toss them into the…
/* 大连热身D题 题意: 有n个人,m个浴室每个浴室有ai个喷头,每个人等概率得选择一个浴室. 每个浴室的人都在喷头前边排队,而且每个浴室内保证大家都尽可能均匀得在喷头后边排队. 求所有浴室中最长队伍的期望. 思路: 概率dp dp[i][j][k]代表前i个浴室有j个人最长队伍是k的概率. 枚举第i个浴室的人数.然后转移的时候其实是一个二项分布. */ #include<bits/stdc++.h> using namespace std; ]; ][][]; ][]; void init…
题意:你从0开始,要跳到 n 这个位置,如果当前位置是一个飞行点,那么可以跳过去,要不然就只能掷骰子,问你要掷的次数数学期望,到达或者超过n. 析:概率DP,dp[i] 表示从 i  这个位置到达 n 要掷的次数的数学期望.然后每次掷的数就是1-6,概率都相等为1/6,再特殊标记一下飞行点,那么就容易写过了. 代码如下: #pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #in…
题意:给定 n 类bug,和 s 个子系统,每天可以找出一个bug,求找出 n 类型的bug,并且 s 个都至少有一个的期望是多少. 析:应该是一个很简单的概率DP,dp[i][j] 表示已经从 j 个子系统中,找出 i 种类型的bug,达到目标所需要天数的期望, 很明显dp[n][s] = 0.0,而dp[0][0] 就是答案,剩下的就比较简单了, dp[i][j] = (dp[i+1][j]*(n-i)*j + dp[i][j+1]*i*(s-j) + dp[i+1][j+1]*(n-i)*…