Test instructions: How many ways are there to cover N*m's chessboard with a 1*2 domino?
This problem note do not follow the White Book MAXN open to 15, because every time to memset if open to 15 will tle, open to 11 can
#include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <iostream > #include <algorithm> #include <vector> #include <map> #include <queue> #include <stack& Gt #include <string> #include <map> #include <set> #define EPS 1e-6 #define LL Long Long #define PII (pair< int, int>)//#pragma comment (linker, "/stack:1024000000,1024000000") using namespace std; const int INF = 0x3f3f3f3f;//freopen ("Input.txt", "R", stdin); int n, m, cur;const int maxn = 11; LL D[2][1<<maxn];int Main () {while (scanf ("%d%d", &n, &m) = = 2) {if (M > N) swap (m, n); cur = 0;memset (d[cur ], 0, sizeof (D[cur])); d[cur][(1<<m)-1] = 1;for (int i = 0; i < n; i++) for (int j = 0; J < m; J + +) {cur ^= 1;memset (D[cur], 0, sizeof (d [cur])); for (int k = 0; k < (1<<m); k++) {if (k& (1<< (m-1))) d[cur][(k<<1) ^ (1<<m)] + = d[1-cur][k];//No Put if (i &&!) ( k& (1<< (m-1))) D[cur][(k<<1) +1] + = D[1-cur][k];if (J &&! k&1) && (k& (1<< (m-1))) d[cur][(k<<1) ^ (1<<m) |3] + = d[1-cur][k]; }} LL ans = d[cur][(1<<m)-1];p rintf ("%lld\n", ans);} return 0;}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
UVA 11270 Tiling Dominoes (contour line DP Classic)