标签:
Description
Input
Output
Sample Input
1 2
1 3
1 4
2 2
2 3
2 4
2 11
4 11
0 0
Sample Output
1
0
1
2
3
5
144
51205
Source
1 //It is made by jump~ 2 #include <iostream> 3 #include <cstdlib> 4 #include <cstring> 5 #include <cstdio> 6 #include <cmath> 7 #include <algorithm> 8 #include <ctime> 9 #include <vector> 10 #include <queue> 11 #include <map> 12 #include <set> 13 using namespace std; 14 typedef long long LL; 15 const int MAXN = 11; 16 const int MAXS = (1<<11); 17 int n,m; 18 LL f[2][MAXS]; 19 20 inline void solve(){ 21 memset(f,0,sizeof(f)); 22 int end=(1<<m)-1; int tag=1; 23 f[1][end]=1;//注意初值的设定!!! 24 for(int i=0;i<n;i++) 25 for(int j=0;j<m;j++){ 26 tag^=1; memset(f[tag],0,sizeof(f[tag])); 27 for(int k=0;k<=end;k++) { 28 if((k<<1)&(1<<m)) f[tag][(k<<1)^(1<<m)]+=f[tag^1][k];//这一个格子不放 29 if(i && ( !((k<<1)&(1<<m)) )) f[tag][(k<<1)^1]+=f[tag^1][k];//往上放 30 if(j && (!(k&1)) && ((k<<1)&(1<<m))) f[tag][(k<<1)^3^(1<<m)]+=f[tag^1][k];//往左放 31 } 32 } 33 printf("%lld\n",f[tag][end]); 34 } 35 36 inline void work(){ 37 while(1) { 38 scanf("%d%d",&n,&m); if(n==0 && m==0) break; 39 if((n*m)%2==1) { printf("0\n"); continue; } 40 if(n<m) swap(n,m); 41 solve(); 42 } 43 } 44 45 int main() 46 { 47 work(); 48 return 0; 49 }
标签:
原文地址:http://www.cnblogs.com/ljh2000-jump/p/5876529.html