hdu4336 Card Collector 容斥原理】的更多相关文章

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 smart boy, you notice that to win t…
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…
Card Collector Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5254    Accepted Submission(s): 2676Special Judge Problem Description In your childhood, do you crazy for collecting the beautiful…
题意: 买东西集齐全套卡片赢大奖.每个包装袋里面有一张卡片或者没有. 已知每种卡片出现的概率 p[i],以及所有的卡片种类的数量 n(1<=n<=20). 问集齐卡片需要买东西的数量的期望值. 一开始,自己所理解的期望值是原来学过的  一个值*它自身发生的概率,这没错,但是不知道在这一题里面 那个值是多少 经过重重思考和挣扎最后明白了,这一题中,n就是那个值,也是你要求的,感觉理解这个好难,但是好重要, 此题中,将n设置为 dp[0] 可以这样想,你要买sum包,才能集齐n种卡片,那么 你最后…
读完题目就知道要使用容斥原理做! 下面用的是二进制实现的容斥原理,详见:http://www.cnblogs.com/xin-hua/p/3213050.html 代码如下: #include<iostream> #include<stdio.h> #include<algorithm> #include<iomanip> #include<cmath> #include<cstring> #include<vector>…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4336 题意:买食品收集n个卡片,每个卡片的概率分别是pi,且Σp[i]<=1,求收集n个卡片需要买的食品数的期望. 压缩DP:把每个食品用二进制表示,0和1分别表示没有卡片和已经收集到此卡片的期望,则 f[s]=(1-Σp[i])*f[s]+Σp[j]*f[s]+Σp[k]*f[s|(1<<k)] s表示状态,i表示所有卡片编号,j表示s状态中已经有的卡片编号,k表示s状态中没有的卡片编号…
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 smart boy, you…
题目链接 hdu4336 题解 最值反演 也叫做\(min-max\)容斥,在计算期望时有奇效 \[max\{S\} = \sum\limits_{T \in S} (-1)^{|T| + 1}min\{T\}\] 证明: 记\(S = \{a_i\}\),其中对于\(i < j\)有\(a_i < a_j\) 那么我们计算每一个\(a_i\)的贡献,有 \[ \begin{aligned} \sum\limits_{T \in S} (-1)^{|T| + 1}min\{T\} &=…
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 smart boy, you notice that to win t…
题目传送门 https://vjudge.net/problem/HDU-4336 http://acm.hdu.edu.cn/showproblem.php?pid=4336 题解 minmax 容斥模板题. 一个集合 \(S\) 的至少有一个邮票出现的最早时间是 \(\frac 1{\sum\limits_{i\in S} p_i}\). 时间复杂度 \(O(2^n)\). #include<bits/stdc++.h> #define fec(i, x, y) (int i = head…