原题:ZOJ 3777  http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3777 题意:给每个题目安排在每个位置的value.有一个程序随机选择安排的顺序,总的value值大于等于m时,就可以接受这个安排.问能够获得一次满足条件的安排的期望次数. 这题不会做,看网上是用状态压缩DP做的. 定义: dp[i][j]为选取了前i行,趣味和为j的方案种数. 由于程序是每次随机选择一个排列,每次的选择之间不影响,而且每次选中的概…
题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3777 Time Limit: 2 Seconds      Memory Limit: 65536 KB The 11th Zhejiang Provincial Collegiate Programming Contest is coming! As a problem setter, Edward is going to arrange the order…
The 11th Zhejiang Provincial Collegiate Programming Contest is coming! As a problem setter, Edward is going to arrange the order of the problems. As we know, the arrangement will have a great effect on the result of the contest. For example, it will…
LINK:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3777 题意:有N(\( N <= 12 \))道题,排顺序,当某道题选择了放在第j个位置时,会获得Pij的点数,但其他题目就不能选择j位置了.要求总获得的点数要大于M(\(1 <= M <= 500\)),问在所有方案中选择出合法方案的次数的期望值. 思路:题目要求的期望值,比较简单,就是总方案数和合法方案数的比值.看题目就知道是个DP,重点在于状态设计…
Simple String Problem Recently, you have found your interest in string theory. Here is an interesting question about strings. You are given a string S of length n consisting of the first k lowercase letters. You are required to find two non-empty sub…
B - Problem Arrangement Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%lld & %llu Submit Status Practice ZOJ 3777 Description The 11th Zhejiang Provincial Collegiate Programming Contest is coming! As a problem setter, Edward is going…
原题: UVA 1169  http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3610 大白书上的原题. 代码: #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <algor…
原题:UVA 1172  http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3613 动态规划问题. 定义: dp[i] = 右岸前i个村庄(m岸)能够与左岸(n岸)不交叉匹配的最大权值和最小桥数 (用pair<int,int> 维护两个值) 方程: dp[i].first = max(dp[i].first,dp[i-1].fir…
首先,定义S,表示前k个字符出现的集合,用二进制来压缩. 接下来,推出dp1[S],表示集合为S的子串的最长长度. 然后根据dp1[S]再推出dp2[S],表示集合为S或S的子集的子串的最长长度. 最后答案就是max(dp2[S]*dp2[补(S)]) #include<cstdio> #include<cstring> #include<algorithm> using namespace std; <<]; int main(){ int t,n,k;…
原题: HDU 3362 http://acm.hdu.edu.cn/showproblem.php?pid=3362 开始准备贪心搞,结果发现太难了,一直都没做出来.后来才知道要用状压DP. 题意:题目给出n(n <= 18)个点的二维坐标,并说明某些点是被固定了的,其余则没固定,要求添加一些边,使得还没被固定的点变成固定的,可见题目中的图形sample. 由于n很小,而且固定点的顺序没有限制,所以需要用状态压缩DP. 注意:1.当一个没固定的点和两个固定了的点连接后,该点就被(间接)固定了(…