- Mondriaan's Dream
- 对拍
- @ 2025-6-28 11:00:48
#include<bits/stdc++.h>
#define int long long 
using namespace std;
const int N=12;
int n,m;
int f[N][1<<N];
bool check(int x)
{
	int sum=0;
	for(int i=0;i<m;i++)
	{
		if(x&(1<<i))
		{
			if(sum&1)return 0;
			sum=0;
		}
		else sum++;
	}
	if(sum&1)return 0;
	return 1;
}
signed main()
{
	while(1)
	{
		cin>>n>>m;
		if(!n)break;
		if((n*m)&1)
		{
			cout<<"0\n";
			continue;
		}
		memset(f,0,sizeof f);
		
		int U=(1<<m)-1;
		for(int i=0;i<=U;i++)
			if(check(i))
				f[1][i]=1;
		for(int i=2;i<=n;i++)
			for(int now=0;now<=U;now++)
				for(int pre=0;pre<=U;pre++)
					if(!(pre&now) && check(now|pre))
						f[i][now]+=f[i-1][pre];
		cout<<f[n][0]<<"\n";
	}
	return 0;
}
0 comments
  
  No comments so far...
            Information
- ID
- 405
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 6
- Tags
- # Submissions
- 26
- Accepted
- 11
- Uploaded By
 
      