[Cpp]
/*
The normal solution times out, and the table passes through.
Define the status by yourself. In my solution, landscape blocks [0, 0] and landscape blocks [1, 0], where 1 indicates the lower layer.
You can also use a horizontal block [0, 0] and a vertical block [1, 2], but there will be an extra state, which requires a three-digit representation.
*/
// Table playing program
# Include <cstdio>
# Include <cstring>
_ Int64 h, w;
_ Int64 d [11] [1 <11];
_ Int64 check1 (_ int64 x) // The connected 0 must be an even number.
{
_ Int64 I;
_ Int64 z = 0;
For (I = 0; I <w; ++ I)
{
If (x & (1 <I ))
{
If (z % 2! = 0) return 0;
Z = 0;
}
Else
Z ++;
}
If (z % 2! = 0) return 0;
Return 1;
}
_ Int64 check2 (_ int64 x, _ int64 y) // checks whether the two statuses x and y meet the conditions.
{
If (x & y) return 0;
_ Int64 tmp = x | y;
Return check1 (tmp );
}
_ Int64 max (_ int64 a, _ int64 B)
{
Return a> B? A: B;
}
Int main ()
{
Freopen ("e: // data. out", "w", stdout );
For (h = 1; h <= 11; ++ h)
For (w = 1; w <= 11; + + w)
{
_ Int64 up = (1 <w );
_ Int64 I, j, k;
Memset (d, 0, sizeof (d ));
For (I = 0; I {
For (j = 0; j <up; ++ j)
{
If (I = 0)
{
If (! Check1 (j) continue;
D [I] [j] = 1;
}
Else
{
For (k = 0; k <up; ++ k)
{
If (check2 (j, k ))
{
D [I] [j] + = d [I-1] [k];
}
}
}
}
}
Printf ("% I64d,", d [h-1] [0]);
}
Return 0;
}
// Main program
# Include <cstdio>
_ Int64 A [] = {89,144, 0,153, 0,571, 281,781,224, 0,781, 34,153,224, 89,571,180, 0,144,, 0 };
Int main () www.2cto.com
{
Int h, w;
While (scanf ("% d", & h, & w )! = EOF)
{
If (! H &&! W) break;
H --;
W --;
Printf ("% I64d \ n", A [h * 11 + w]);
}
Return 0;
}