poj 2663 压缩DP
来源:互联网 发布:sql 数据库置疑 编辑:程序博客网 时间:2024/05/17 06:33
#include<stdio.h>#include<string.h>#include<math.h>#include<string>#include<iostream>#include<algorithm>using namespace std;long long dp[33][1<<4];int map[1<<4][1<<4];int n,m;void dfs(int x,int y,int dep){ if(dep==m){ map[x][y]=1; return; } int t1=(x>>dep)&1; if(dep==m-1){ if(t1) dfs(x,y,dep+1); else dfs(x,y+(1<<dep),dep+1); return ; } int t2=(x>>(dep+1))&1; if((!t1)&&(!t2)){ dfs(x,y,dep+2); dfs(x,y+(1<<dep),dep+1); } if((!t1) && t2){ dfs(x,y+(1<<dep),dep+2); } if(t1){ dfs(x,y,dep+1); }}long long deal(){ if(m==0) return 1; if(n*m %2) return 0; memset(map,0,sizeof(map)); for(int x=0;x<(1<<m);x++) dfs(x,0,0); memset(dp,0,sizeof(dp)); dp[0][0]=1; for(int i=1;i<=n;i++){ for(int x=0;x<(1<<m);x++) if(dp[i-1][x]) for(int y=0;y<(1<<m);y++){ if(map[x][y]) dp[i][y]+=dp[i-1][x]; } } return dp[n][0];}int main(){// freopen("in.in","r",stdin); while(~scanf("%d",&n)&&(n!=-1)){ m=min(n,3); n=max(n,3); cout<< deal() << endl; } return 0;}
0 0
- poj 2663 压缩DP
- poj 2411(压缩dp)
- poj 1038 状态压缩dp 四进制压缩
- 【状态压缩DP】POJ 1170
- 【状态压缩DP】POJ 1185
- POJ 3254 状态压缩DP
- POJ 2411 位压缩dp
- poj 3254 状态压缩dp
- POJ 2923(dp + 状态压缩)
- poj 3254 状态压缩DP
- poj 1185(状态压缩dp)
- poj 3254(状态压缩dp)
- poj 3311(状态压缩dp)
- poj-2411-状态压缩DP
- POJ 3254 状态压缩DP
- Poj 2404 状态压缩DP
- poj 2411 状态压缩dp
- poj 2411 状态压缩DP
- JVM和DVM的区别,你知道吗?
- cas入门之二十八:services管理控制台
- 内存泄露(一)
- D - I Think I Need a Houseboat(1.3.1)
- c语言字符串 数字转换函数大全(转载)
- poj 2663 压缩DP
- 伸展树
- FPGA机器学习之stanford机器学习第十六堂
- boa服务器及cgic库的安装及使用
- hdu 1394 暴力
- 在海思3511上面实现wifi模块变成ap站点功能+wifi rt3070驱动的移植
- (未完成)matlab--矩阵运算技巧
- 需要手工register logfile的情况
- TQ210_裸机编程(三)——串口通信