二进制博大精深
#include <stdio.h>
#include <string.h>
int n,m;
__int64 dp[12][1<<12],tmp;
void dfs(int p,int s,int pos)//行 状态 位置
{
if( pos == m ){
dp[p][s] += tmp;
return;
}
dfs( p,s,pos+1 );
if(( pos <= m-2 ) && !(s&(1<<pos)) && !(s&1<<pos+1) ) //横着放
dfs( p,s|(1<<pos)|(1<<pos+1),pos+2 );
}
int main()
{
#ifndef ONLINE_JUDGE
freopen("data.txt","r",stdin);
#endif
while( scanf("%d%d",&n,&m) != EOF,(n||m) ){
if( n < m ){
n = n^m; m = n^m; n = n^m;
}
memset( dp,0,sizeof(dp) );
tmp = 1;
dfs(1,0,0);
for( int i = 2; i <= n; i ++ ){
for(int j=0; j < (1<<m);j ++){
if( dp[i-1][j] )
tmp = dp[i-1][j];
else
continue;
dfs(i,(~j)&((1<<m)-1),0);
}
}
printf("%lld\n",dp[n][(1<<m)-1]);
}
return 0;
}