
压状dp
文章平均质量分 64
IED98
这个作者很懒,什么都没留下…
展开
-
bzoj2734: [HNOI2012]集合选数 压状dp
写出如下矩阵 1 3 9 27... 2 6 18 54... 4 12 36 108... 发现最多有11列。。。 我们在其中选取一些数,相邻的不能选择 然后就可以状压求方案数了,但是5没有出现,同样5的倍数也没有出现,7也如此。。 应该记录哪些数字出现过,没出现过就作为矩阵的第一个元素,最后把若干个矩阵的方案相乘 #include #inclu原创 2015-01-05 22:25:53 · 639 阅读 · 0 评论 -
bzoj1076: [SCOI2008]奖励关 压状dp
有个技巧,从后往前推,这样方便很多,由于可以取多次,所以状态转移的时候只能用“|”#include #include #include #include #include using namespace std; double f[110][1<<15]; int need[110],n,m,k,val[110]; int main() { int tmp,a,b; sc原创 2015-01-08 21:50:37 · 486 阅读 · 0 评论 -
bzoj1087: [SCOI2005]互不侵犯King 压状dp
先枚枚举每一行的棋子分布情况,再对各种情况进行判断,这样可以减少枚举次数。#include #include #include #include #include #include #include using namespace std; typedef long long sint; int n,m; sint f[10][(1<<10)][100]; bool flag[1<<原创 2015-01-05 21:04:44 · 517 阅读 · 0 评论 -
bzoj1072: [SCOI2007]排列perm 压状dp
二进制位表示每一位的数字用过没有,第二维表示当前这个数%d等于几,由于有相同的数所以结尾要除以sum[I]! (0#include #include #include #include #include #include using namespace std; int dp[1<<11][1010]; int fac[15],n,m,d,a[15],sum[15]; void get原创 2015-01-20 12:53:56 · 460 阅读 · 0 评论 -
bzoj2891: 匹配难题 压状dp
由于人很少,我们可以用longlong进行位运算记录 每个人匹配的状态,根据hall定理我们可以知道很多状态都是不成立的,所以我们先预处理出每种状态之间的关系,把位数太大的数进行hash,然后就跑压状dp了。 #include #include #include #include using namespace std; #define n 105 #define m 400原创 2015-07-13 09:41:39 · 836 阅读 · 0 评论