hdu 4539 郑厂长系列故事――排兵布阵 (状压DP)

2014-11-24 08:50:46 · 作者: · 浏览: 1

同 poj 1185


只是多加一些判断了


就是相邻的行之间 要多加一个哈弗曼为2 的判断


#include 
  
   
#include 
   
     #include 
    
      #include 
     
       using namespace std; int dp[100][200][200],st[200],sum[200],a[100]; int n,m,cnt; int get(int x)//处理出x状态下 能放下的炮台数 就是二进制下的1的数量 { int s=0; while(x) { if(x&1)s++; x>>=1; } return s; } bool J(int x,int y) { if(x&(y<<1))return 0; if(x&(y>>1))return 0; return 1; } int main() { while(scanf("%d%d",&n,&m)!=EOF) { cnt=0; for(int i=0;i