[HDU4336]Card Collector(Min-Max容斥) 题面 Vjudge 题解 原来似乎写过一种状压的做法,然后空间复杂度很不优秀. 今天来补一种神奇的方法. 给定集合\(S\),设\(max\{S\}\)为\(S\)中的最大值,\(min\{S\}\)为集合\(S\)中的最小值. 那么我们可以得到: \(max\{S\}=\sum_{T\subseteq S}(-1)^{|T|+1}min\{T\}\) 证明的话,大概就是如果你钦定一个最小值,并且它强制出现, 如果枚举所有子集…
Card Collector(期望+min-max容斥) Card Collector woc居然在毫不知情的情况下写出一个min-max容斥 题意 买一包方便面有几率附赠一张卡,有\(n\)种卡,每种卡出现的概率是\(p_i\),保证\(\Sigma p_i \le 1\),集齐所有种类卡牌期望买多少包方便面? 解法 看次题解前,你必须要理解当只有一种卡,他出现的概率是\(p\),那么我期望购买$\frac 1 p $包方便面就可以获得这种卡. 否则请你右上角,因为博主不会解释... 唯一的解…
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…
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…
设\(S\)是一个集合,\(\max(S)\)和\(\min(S)\)分别表示集合中的最大值与最小值. 那么有如下式子成立: \[\max(S)=\sum_{T \subseteq S}(-1)^{|T|+1}\min(T)\] \[\min(S)=\sum_{T \subseteq S}(-1)^{|T|+1}\max(T)\] 因为证明很简单就写一下吧,以第一个式子为例,设\(\max(S)=x\),那么只有\(T=\{x\}\)时的\(\min(T)\)为\(x\)(可能有多个相同的最大值…
题意 题目链接 \(N\)个物品,每次得到第\(i\)个物品的概率为\(p_i\),而且有可能什么也得不到,问期望多少次能收集到全部\(N\)个物品 Sol 最直观的做法是直接状压,设\(f[sta]\)表示已经获得了\(sta\)这个集合里的所有元素,距离全拿满的期望,推一推式子直接转移就好了 主程序代码: int N; double a[MAXN], f[MAXN]; signed main() { // freopen("a.in", "r", stdin);…
题目传送门 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…
题目链接 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\} &=…
显然,这题有一种很简单的做法即直接状压卡牌的状态并转移期望的次数.但我们现在有一个更加强大的工具——min-max容斥. min-max 容斥(对期望也成立):\(E[max(S)] = \sum_{T\subseteq S}^{\ }(-1)^{|T| - 1}E[min(T)]\) 我们可以让 \(E[max(S)]\) 表示 \(S\) 中所有元素均出现的期望时间(即最后一个元素出现的期望时间),\(E[min(S)]\) 表示 \(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…