标签:des blog http io ar os sp for strong
| Time Limit: 3000MS | Memory Limit: 65536K | |
| Total Submissions: 12111 | Accepted: 7058 |
Description

Input
Output
For each test case, output the number of different ways the given rectangle can be filled with small rectangles of size 2 times 1. Assume the given large rectangle is oriented, i.e. count symmetrical tilings multiple times.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
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<vector>
#include<set>
using namespace std;
#define LL long long
LL dp[12][1<<11+1];
int path[140000][2],h,w,temp,tann;
void dfs(int l,int now,int pre)
{
if(l>w)
return ;
if(l==w)
{
path[tann][0]=now;
path[tann++][1]=pre;
return ;
}
dfs(l+2,(now<<2)|3,(pre<<2)|3);
dfs(l+1,(now<<1)|1,pre<<1);
dfs(l+1,now<<1,(pre<<1)|1);
}
int main()
{
while(scanf("%d%d",&h,&w)!=EOF)
{
tann=0;
memset(dp,0,sizeof(dp));
memset(path,0,sizeof(path));
if(h==0&&w==0)
{
break;
}
if(w>h)
{
temp=w;
w=h;
h=temp;
}
dfs(0,0,0);
dp[0][(1<<w)-1]=1;
for(int i=0;i<h;i++)
for(int j=0;j<tann;j++)
dp[i+1][path[j][0]]+=dp[i][path[j][1]];
printf("%lld\n",dp[h][(1<<w)-1]);
}
return 0;
}
标签:des blog http io ar os sp for strong
原文地址:http://www.cnblogs.com/a972290869/p/4101158.html