Mondriaan's Dream
Time Limit: 3000MS Memory Limit: 65536K
Total Submissions: 18903 Accepted: 10779
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 Ulm Local 2000

状压DP,二分图的前身

预处理长度为m的二进制数中是否有连续奇数个0

f[i][j] 第i行,形态为j(2),的方案数

#include<iostream>
#include<cmath>
using namespace std; int n,m; long long f[12][1<<12];
bool jug[1<<12];
int main(){
while(cin>>n>>m){
if(!n) return 0;
for(int i=0;i<1<<m;i++){
bool ans=0,cnt=0;
for(int k=0;k<m;k++)
if((i>>k)&1) ans|=cnt,cnt=0;
else cnt^=1;
ans|=cnt;
jug[i]=!ans;//NO '~'
}
f[0][0]=1;
for(int i=1;i<=n;i++){
for(int j=0;j<1<<m;j++){
f[i][j]=0;//
for(int k=0;k<1<<m;k++){
if(jug[k|j]&&!(j&k)){
f[i][j]+=f[i-1][k];
}
}
}
}
cout<<f[n][0]<<endl;
}
return 0;
}

最新文章

  1. js压缩图片base64长度
  2. windbg symbol path
  3. 【读书笔记】iOS网络-同步请求,队列式异步请求,异步请求的区别
  4. oj 1031 random permutation
  5. node.js 包教不包会 (Windows版详解)
  6. Fragment 和 FragmentActivity的使用(二)
  7. Ember.js demo3
  8. SqlServer 还原,备份 Sql脚本命令
  9. 在Selenium Webdriver中使用XPath Contains、Sibling函数定位
  10. 嵌入式linux网络配置
  11. scoke摘要
  12. ssh用法及命令
  13. sql sever insert into混合嵌套插入
  14. [Swift]LeetCode191. 位1的个数 | Number of 1 Bits
  15. JavaScript学习day2 (基本语法上)
  16. Delphi编译选项
  17. spring AOP capbilities and goal
  18. python多线程与多进程--存活主机ping扫描以及爬取股票价格
  19. 如何在eclipse安装apk包
  20. 【Boost】boost::tokenizer详解

热门文章

  1. JSP技术概念
  2. 如何使用Tomcat自带的日志实现tomcat-juli.jar
  3. oracle tps
  4. 174. 删除链表中倒数第n个节点
  5. Unity Shader入门精要学习笔记 - 第11章 让画面动起来
  6. cvLoadImage,cvCloneImage的内存泄露问题
  7. git处理时的问题
  8. spring 配置多个properties
  9. 悦读FM客户端应用源码
  10. mysql ERROR 2002 (HY000): Can&#39;t connect to local MySQL server through socket &#39;/var/run/mysqld/mysqld.sock&#39; (2 &quot;No such file or directory&quot;)