传送门 解题思路 第一种方法是状压\(dp\),设\(f(S)\)为状态\(S\)到取完的期望步数,那么\(f(S)\)可以被自己转移到,还可以被\(f(S|(1<<i))\)转移到,\(i\)为\(S\)中没有的一个元素. 第二种方法是\(Min-Max\)反演,要求的其实就是\(max(S)\),反演得\(max(S)=\sum\limits_{T\subseteq S}min(T)\),而\(min(T)=\sum p(i)\)(\(i\)是\(T\)的子集). 代码 状压 #inclu…
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种卡片.每买一袋零食,有可能赠送一张卡片,也可能没有. 每一种卡片赠送的概率为p[i],问你将n种卡片收集全,要买零食袋数的期望. 题解: 表示状态: dp[state] = expectation state表示哪些卡片已经有了 找出答案: ans = dp[0] 什么都没有时的期望袋数 如何转移: 两种情况,要么得到了一张新的卡片,要么得到了一张已经有的卡片或者啥都没有.…
Resource Archiver Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 100000/100000 K (Java/Others)Total Submission(s): 2382    Accepted Submission(s): 750 Problem Description Great! Your new software is almost finished! The only thing left to…
Wireless Password Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 5640    Accepted Submission(s): 1785 Problem Description Liyuan lives in a old apartment. One day, he suddenly found that there…
题目链接: 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,…
正解:期望 解题报告: 传送门! 先放下题意,,,已知有总共有$n$张卡片,每次有$p_i$的概率抽到第$i$张卡,求买所有卡的期望次数 $umm$看到期望自然而然想$dp$? 再一看,哇,$n\leq 20$,那不就,显然考虑状压$dp$? 转移也很$easy$鸭,设$f_{s}$表示已经获得的卡片状态为$s$时候的期望次数 不难得到转移方程,$f_s=\sum_{i\notin{S}}f_{s|\{i\}}\cdot p_i+(1-\sum_{i\notin{S}}p_i)\cdot f_s…
题目链接 The input contains mutiple testcases. Please process till EOF.For each testcase, the first line contains two integers N (1 ≤ N ≤ 15), the side length of the square map and M (1 ≤ M ≤ 15), the number of tunnels.The map of the city is given in the…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5765 [题目大意] 给出一张图,求每条边在所有边割集中出现的次数. [题解] 利用状压DP,计算不同的连通块,对于每条边,求出两边的联通块的划分方案数,就是对于该点的答案. [代码] #include <cstdio> #include <algorithm> #include <cstring> using namespace std; int n,m,T,Cas=1…