[poj P2411] Mondriaan's Dream

Time Limit: 3000MS   Memory Limit: 65536K
Total Submissions: 18023   Accepted: 10327

Description

Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, after producing the drawings in his 'toilet series' (where he had to use his toilet paper to draw on, for all of his paper was filled with squares and rectangles), he dreamt of filling a large rectangle with small rectangles of width 2 and height 1 in varying ways. 

Expert as he was in this material, he saw at a glance that he'll need a computer to calculate the number of ways to fill the large rectangle whose dimensions were integer values, as well. Help him, so that his dream won't turn into a nightmare!

Input

The input contains several test cases. Each test case is made up of two integer numbers: the height h and the width w of the large rectangle. Input is terminated by h=w=0. Otherwise, 1<=h,w<=11.

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

 
哎,我好弱啊。。。
一个状压DP都想不到。。。
先列出总转移方程:f[i][j]=sigma(ok(j,k))f[i-1][k]。
其中j,k是二进制状态,i是第几行。
那么,我们无非就是考虑第i行和第i-1行的状态是否兼容。
如何判断是否兼容?
对于两行k,k+1两个状态,第i位分别为u和d。
我们设状态里面“1”表示当前的格子已经被填了,且是被上一行填入;“0”表示未被填。
如果u==1且d==0,我们可以只能跳到下一列进行判断;否则,
如果u==1且d==1,显然这个状态是不合法的;否则,
如果u==0且d==0,那么上面那一行的下一列必定填入一个横排(且当前为0,表示还没有被填入),我们可以将它当做是被上一行填入的(即更改k行下一列的状态,0->1);否则
如果u==0且d==1,显然正好是当前列放一块竖的。
code:
 #include<cstdio>
 #include<cstring>
 #include<algorithm>
 #include<vector>
 #define LL long long
 #define idx(x,i) ((x>>i)&1)
 using namespace std;
 ;
 <<lim];
 vector <<<lim];
 bool jug(int su,int sd) {
     ; i<m; i++) {
         int ku=idx(su,i),kd=idx(sd,i);
         if (!kd&&ku) continue;
         ; else
         if (!kd) {
             &&!idx(su,i+)) su|=<<(i+); ;
         }
     }
     ;
 }
 int main() {
     while (scanf("%d%d",&n,&m),n|m) {
         S=<<m;
         ; i<S; i++) o[i].clear();
         ; i<S; i++)
             ; j<S; j++) if (jug(i,j)) o[j].push_back(i);
         memset(f,,][]=;
         ; i<=n; i++)
             ; j<S; j++)
                 ,s=o[j].size(); k<s; k++)
                 f[i][j]+=f[i-][o[j][k]];
         printf(]);
     }
     ;
 }

[poj P2411] Mondriaan's Dream的更多相关文章

  1. PKU P2411 Mondriaan's Dream

    PKU P2411 Mondriaan's Dream 题目描述: Squares and rectangles fascinated the famous Dutch painter Piet Mo ...

  2. POJ 2411 Mondriaan's Dream -- 状压DP

    题目:Mondriaan's Dream 链接:http://poj.org/problem?id=2411 题意:用 1*2 的瓷砖去填 n*m 的地板,问有多少种填法. 思路: 很久很久以前便做过 ...

  3. POJ 2411 Mondriaan's Dream 插头dp

    题目链接: http://poj.org/problem?id=2411 Mondriaan's Dream Time Limit: 3000MSMemory Limit: 65536K 问题描述 S ...

  4. POJ - 2411 Mondriaan's Dream(轮廓线dp)

    Mondriaan's Dream Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One nig ...

  5. [POJ] 2411 Mondriaan's Dream

    Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 18903 Accepted: 10779 D ...

  6. [poj 2411]Mondriaan's Dream (状压dp)

    Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 18903 Accepted: 10779 D ...

  7. Poj 2411 Mondriaan's Dream(状压DP)

    Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Description Squares and rectangles fascina ...

  8. Poj 2411 Mondriaan's Dream(压缩矩阵DP)

    一.Description Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, ...

  9. poj 2411 Mondriaan's Dream(状态压缩dp)

    Description Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, af ...

随机推荐

  1. 如何知道网页浏览器cookie是什么?

    一直有网友问网页cookie如何获取,其实想知道自己访问网页时的cookie没那么难,用Chrome内核浏览器的debug功能就能看到,怎么查看呢?随ytkah一起来看看吧! 打开网页,按F12键,选 ...

  2. 002-自定义打开terminal,以及快捷键,其他程序类似,ssh管理-sshpass, Shuttle

    一.利用Automator软件完成服务设定 1.使用Command+Space,打开Spotlight,搜索Automator 2.搜索到之后,双击打开,选择“服务[或快速操作]” 3.将“服务收到[ ...

  3. [elk]elasticsearch dsl语句

    例子1 统计1,有唱歌兴趣的 2,按年龄分组 3,求每组平均年龄 4,按平均年龄降序排序 sql转为dsl例子 # 每种型号车的颜色数 > 1的 SELECT model,COUNT(DISTI ...

  4. ASP.NET MVC案例教程(二)

    ASP.NET MVC案例教程(二) 让第一个页面跑起来 现在,我们来实现公告系统中的第一个页面——首页.它非常简单,只包括所有公告分类的列表,并且每个列表项是一个超链接.其中分类数据是用我们的Moc ...

  5. 2014西安赛区C题

    将A[i]同他后面比他小的建边,然后求最大密度子图 #include <iostream> #include <algorithm> #include <string.h ...

  6. Eclipse启动报错An internal error occurred during: "Initializing Java Tooling"

    Eclipse启动报错An internal error occurred during: "Initializing Java Tooling" 解决方案: 删除工作空间work ...

  7. MongoSpark 28799错误

    Exception : . The full response is { , "codeName" : "Location28799" } at com.mon ...

  8. C++ WINDOWS 防多开

    我们有些程序是可以同时运行多个进程,典型的像Visual Studio.但有些就能一次运行一个进程.比如Outlook.那你可能会问啥时可以让它同时打开多个应用程序,啥时只能一个啊.这个主要看进程间是 ...

  9. springboot使用hibernate validator校验

    一.参数校验 在开发中经常需要写一些字段校验的代码,比如字段非空,字段长度限制,邮箱格式验证等等,写这些与业务逻辑关系不大的代码个人感觉有两个麻烦: 验证代码繁琐,重复劳动 方法内代码显得冗长 每次要 ...

  10. JavaScript 序列化、转义

    JavaScript  序列化.转义 序列化 // 将对象转换为字符串 JSON.stringify() // 将字符串转换为对象类型 JSON.parse() 转义 // URl中未转义的字符 de ...