http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem= 2245
Test instructions: The number of programs that use a 1x2 piece to fill the NXM board. (nxm<=100)
#include <bits/stdc++.h>using namespace Std;long long d[2][1<<10], N, m;int main () {while (~scanf ("%d%d", & Amp;n, &m)) {if (m>n) swap (M, n), int now=0, last=1, all= (1<<m)-1, up=1<< (m-1); for (int i=0; i<=all; + +i) d[last][i]=0;d[last][all]=1;for (int i=1; i<=n; ++i) for (int. j=1; j<=m; ++j) {for (int s=0; s<=all; ++s) D[now] [S]=0;for (int s=0; s<=all; ++s) if (D[last][s]) {int goal= (s<<1) &all;if (i!=1 &&!) ( S&up) d[now][goal|1]+=d[last][s];if (j!=1 &&!) ( s&1) && (s&up)) d[now][goal|3]+=d[last][s];if (s&up) d[now][goal]+=d[last][s];} Swap (now, last);} printf ("%lld\n", D[last][all]);} return 0;}
Classic question .... Contour Line DP ... Set the status of each lattice, then record the status of the above contour lines, then consider three kinds of transfer:
1, this lattice is not covered, the current grid does not cover
2, this lattice is not covered, with a piece of pieces covering the top and the current point
3. There is no overlay on the left side of this lattice and overlay on the top, with a piece of pawn covering the left and the current point
Then notice open long long ...
"UVa" Tiling Dominoes