题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4336 题目大意:有n种卡片,需要吃零食收集,打开零食,出现第i种卡片的概率是p[i],也有可能不出现卡片.问你收集齐n种卡片,吃的期望零食数是多少? 状态压缩:f[mask],代表收集齐了mask,还需要吃的期望零食数. 打开包装,有3种情况,第一种:没有卡片,概率(1-sigma(p[i])) 第二种,在已知种类中:概率sigma(p[j]) 第三种,在未知种类中:p[k] 因此 f[mask]…
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…
题意:有N(1<=N<=20)张卡片,每包中含有这些卡片的概率,每包至多一张卡片,可能没有卡片.求需要买多少包才能拿到所以的N张卡片,求次数的期望. 析:期望DP,是很容易看出来的,然后由于得到每张卡片的状态不知道,所以用状态压缩,dp[i] 表示这个状态时,要全部收齐卡片的期望. 由于有可能是什么也没有,所以我们要特殊判断一下.然后就和剩下的就简单了. 另一个方法就是状态压缩+容斥,同样每个状态表示收集的状态,由于每张卡都是独立,所以,每个卡片的期望就是1.0/p,然后要做的就是要去重,既然…
题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=4336 Card Collector Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) 问题描述 In your childhood, do you crazy for collecting the beautiful cards in the snacks? They said that,…
Problem Description In your childhood, people in the famous novel Water Margin, you will win an amazing award. As a smart boy, you notice that to win the award, you must buy much more snacks than it seems to be. To convince your friends not to waste…
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…
题目链接 Card Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 2711    Accepted Submission(s): 1277Special Judge Problem Description In your childhood, do you crazy for collecting the beaut…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4336 题意: 有n种卡片(n <= 20). 对于每一包方便面,里面有卡片i的概率为p[i],可以没有卡片. 问你集齐n种卡片所买方便面数量的期望. 题解: 状态压缩. 第i位表示手上有没有卡片i. 表示状态: dp[state] = expectation (卡片状态为state时,要集齐卡片还要买的方便面数的期望) 找出答案: ans = dp[0] 刚开始一张卡片都没有. 如何转移: now:…
Card Collector Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1708 Accepted Submission(s): 780 Special Judge Problem Description In your childhood, do you crazy for collecting the beautiful cards…
思路:反状态压缩——把数据转换成20位的01来进行运算 因为只有20位,而且&,|,^都不会进位,那么一位一位地看,每一位不是0就是1,这样求出每一位是1的概率,再乘以该位的十进制数,累加,就得到了总体的期望. 对于每一位,状态转移方程如下: f[i][j]表示该位取前i个数,运算得到j(0或1)的概率是多少. f[i][1]=f[i-1][1]*p[i]+根据不同运算符和第i位的值运算得到1的概率. f[i][0]=f[i-1][0]*p[i]+根据不同运算符和第i位的值运算得到0的概率. 初…