[SGU495] Kids and Prizes (概率dp)】的更多相关文章

题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=495 题意:有n个盒子,每个盒子里面放了一个奖品,m个人轮流去选择盒子,如果盒子里面有奖品,就把奖品拿走,盒子留下,否则直接走人.求最后被抽走的奖品数期望... 如果直接考虑用期望来建立DP,复杂度都很高,而且题目精度过高.换一个角度思考,考虑每个奖品不被拿走的概率(1/n)^m,那么不被拿走的期望就是n*(1/n)^m,则拿走的期望n-n*(1/n)^m,复杂度O(1).还可以考虑f[i…
题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=495 题目大意:有N个盒子,里面都放着礼物,M个人依次去选择盒子,每人仅能选一次,如果里面有礼物则将礼物取出来,把空盒子放回原位,若没有礼物,则把空盒子放回原位.求礼物被拿走的个数的数学期望. 令 x[i] 代表第i个人拿到的礼物的个数,即值为0或1. 那么,N个人拿到的礼物的个数为 X = Sigma(X[i]). 因此 E[X] = E[Sigma(X[i])] = Sigma(E[X…
题目链接 495. Kids and Prizes Time limit per test: 0.25 second(s)Memory limit: 262144 kilobytes input: standardoutput: standard ICPC (International Cardboard Producing Company) is in the business of producing cardboard boxes. Recently the company organiz…
题目链接:http://acm.sgu.ru/problem.php?contest=0&problem=495 题意: 有n个礼物盒,m个人. 最开始每个礼物盒中都有一个礼物. m个人依次随机选一个盒子,如果有礼物就拿走,然后放回空盒子. 问你所有人得到总礼物数的期望. 题解: 三种做法:期望dp,概率dp,推公式 一.期望dp 表示状态: dp[i] = 该第i个人拿箱子时的总礼物的期望 找出答案: ans = dp[m] 如何转移: 对于第i个人,拿到礼物或没拿到. (1)φ(没拿到) =…
495. Kids and Prizes Time limit per test: 0.25 second(s) Memory limit: 262144 kilobytes input: standard output: standard ICPC (International Cardboard Producing Company) is in the business of producing cardboard boxes. Recently the company organized…
Kids and Prizes ICPC (International Cardboard Producing Company) is in the business of producing cardboard boxes. Recently the company organized a contest for kids for the best design of a cardboard box and selected M winners. There are N prizes for…
概率题..可以dp也可以推公式 抽象出来的题目大意: 有 n个小球,有放回的取m次  问 被取出来过的小球的个数的期望 dp维护两个状态 第 i 次取出的是 没有被取出来过的小球的 概率dp[i] 和取出的是已经被取出来过的小球的概率np[i]; 如果第 i-1 次取出的是已经被取出来过的小球 那么第 i 次取出没有取出来过小球的概率即为 dp[i-1]: 反之则为 dp[i-1] - 1/n(没有取出来过的小球少了一个) 所以可以得到状态转移方程 dp[i]=dp[i-1]*(dp[i-1]-…
专题链接 第一题--poj3744 Scout YYF I  链接 (简单题) 算是递推题 如果直接推的话 会TLE 会发现 在两个长距离陷阱中间 很长一部分都是重复的 我用 a表示到达i-2步的概率 b表示到达i-1步的概率 c表示到达i步的概率 如果数很大的话 中间肯定会有重复的a,b,c 直接将i挪到最近的陷阱前一位 i = a[o]-1,大大节省时间. #include <iostream> #include<cstdio> #include<cstring>…
概率类题目一直比较弱,准备把kuangbin大师傅总结的这篇题刷一下! 我把下面的代码换成了自己的代码! 原文地址:http://www.cnblogs.com/kuangbin/archive/2012/10/02/2710606.html *************************************************************** 概率DP主要用于求解期望.概率等题目. 转移方程有时候比较灵活. 一般求概率是正推,求期望是逆推.通过题目可以体会到这点. 首先…
1,逆推状态:山东省赛2013年I题 Problem I: The number of steps Description 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 stands at the top p…