#include<bits/stdc++.h>
using namespace std;
#define int long long
constexpr int maxh=11+3;
constexpr int maxw=11+3;
constexpr int maxcnt=1<<(maxw+1);
int h,w,ii;
int dp[2][maxcnt];
signed main()
{
while(1)
{
for(int i=0; i<2; ++i)
{
for(int j=0; j<1<<(w+1); ++j)
{
dp[i][j]=0;
}
}
scanf("%lld%lld",&h,&w);
if(!h&&!w)
{
break;
}
dp[0][0]=1;
ii=0;
for(int i=1; i<=h; ++i)
{
ii^=1;
for(int j=0;j<1<<(w+1);++j)
{
dp[ii][j]=0;
}
for(int j=0;j<(1<<w);++j)
{
dp[ii][j<<1]=dp[ii^1][j];
}
for(int j=1;j<=w;++j)
{
ii^=1;
for(int k=0;k<1<<(w+1);++k)
{
dp[ii][k]=0;
}
for(int a=0;a<(1<<(w+1));++a)
{
if(!dp[ii^1][a])
{
continue;
}
int left=(a>>(j-1))&1,up=(a>>(j))&1;
if(left&&up)
{
continue;
}
if(left)
{
dp[ii][a-(1<<(j-1))]+=dp[ii^1][a];
}
else if(up)
{
dp[ii][a-(1<<(j))]+=dp[ii^1][a];
}
else
{
dp[ii][a+(1<<(j))]+=dp[ii^1][a];
dp[ii][a+(1<<(j-1))]+=dp[ii^1][a];
}
}
}
}
printf("%lld\n",dp[ii][0]);
}
return 0;
}P10975 Mondriaan's Dream / 蒙德里安的梦想(轮廓线)
文章信息与版本
文章信息
- 发布
- 2026年6月15日
- 收录
- 2026年6月15日
- 更新
- 2026年11月14日
- 篇幅
- 约 4 分钟