poj 2411 (状态压缩)
来源:互联网 发布:复旦金融硕士 知乎 编辑:程序博客网 时间:2024/06/02 19:45
第一道状态压缩,撒花~~~
/* * ===================================================================================== * * Filename: a.cpp * Version: 1.0 * Created: 2013-08-27 23:01:05 * Revision: none * Compiler: GNU C++ * * Just like you,wait you forever~~ * * ===================================================================================== */#include <set>#include <map>#include <list>#include <queue>#include <stack>#include <cmath>#include <string>#include <cstdio>#include <vector>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>using namespace std;#define PB push_back#define SIZE(x) (int)x.size()#define clr(x,y) memset(x,y,sizeof(x))#define MP(x,y) make_pair(x,y)#define reads(n) scanf ("%s", n)#define ALL(t) (t).begin(),(t).end()#define FOR(i,n,m) for (int i = n; i <= m; i ++)#define ROF(i,n,m) for (int i = n; i >= m; i --)#define IT iterator#define FF first#define SSsecondtypedef long long ll;typedef unsigned int uint;typedef unsigned long long ull;typedef vector<int> vint;typedef vector<string> vstring;typedef pair<int, int> PII;void RI (int& x){ x = 0; char c = getchar (); while (c == ' '||c == '\n')c = getchar (); bool flag = 1; if (c == '-'){ flag = 0; c = getchar (); } while (c >= '0' && c <= '9'){ x = x * 10 + c - '0'; c = getchar (); } if (!flag)x = -x;}void RII (int& x, int& y){RI (x), RI (y);}void RIII (int& x, int& y, int& z){RI (x), RI (y), RI (z);}/**************************************END define***************************************/const ll mod = 1e9+7;const ll LINF = 1e18;const int INF = 1e9;const double EPS = 1e-8;const int N = (1 << 11);int n, m;ll dp[13][N];vint g[N];void init (){ FOR (i, 0, N-1) g[i].clear (); clr (dp, 0);}void dfs (int col, int x, int y){ if (col > n){ g[x].PB (y); return; } dfs (col+1, (x<<1)+1, y<<1); dfs (col+1, x<<1, (y<<1)+1); if (col + 1 <= n) dfs (col+2, x<<2, y<<2);}int main (){ while (cin >> n >> m, n||m){ if (m < n) swap (m, n); init (); dfs (1, 0, 0); dp[1][0] = 1; FOR (i, 1, m){ FOR (j, 0, (1<<n)-1){ FOR (h, 0, SIZE (g[j])-1){ int v = g[j][h]; // cout << j << " " << v << endl; dp[i+1][v] += dp[i][j]; } } } cout << dp[m+1][0] << endl; }}
- poj 2411 (状态压缩)
- poj-2411-状态压缩DP
- poj 2411 状态压缩dp
- poj 2411 状态压缩DP
- POJ 2411 状态压缩DP
- poj 2411 状态压缩dp
- poj 2411 状态压缩dp
- POJ 2411 状态压缩DP
- POJ 2411 状态压缩DP
- poj 2411 (状态压缩dp)
- poj 2411 状态压缩dp
- POJ 2411 状态压缩DP
- POJ 2411 Mondriaan's Dream 状态压缩
- POJ 2411 Mondriaan's Dream(状态压缩)
- poj 2411 状态压缩DP 铺砖块
- poj 2411 状态压缩dp+轮廓线
- POJ 2411 铺地砖 状态压缩dp入门
- poj 2411 状态压缩 多米骨诺牌系列
- Android在OnCreate中获取控件的宽度和高度
- shell脚本重定向>>, >, 2>>, 2>, &>, &>>
- leetcode minimum window substring
- 对话框程序启动时呈现的状态
- 在 Ubuntu 12.04 LTS 上安装 OpenCV 2.4.1
- poj 2411 (状态压缩)
- 关键帧动画CAKeyframeAnimation
- <param name="allowScriptAccess" value="never"/>是什么意思
- Android初级教程_获取Android控件的宽和高
- oracle 子查询解嵌套和谓词推入(sqlsubquery unnest and pre_push)
- POJ1258 &&TOJ3197 Agri-Net
- 回调函数的分析及应用
- VMware桥接上网
- Java-用final修饰方法参数