[POJ] 2411 Mondriaan's Dream
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;
}
[POJ] 2411 Mondriaan's Dream的更多相关文章
- POJ 2411 Mondriaan's Dream 插头dp
题目链接: http://poj.org/problem?id=2411 Mondriaan's Dream Time Limit: 3000MSMemory Limit: 65536K 问题描述 S ...
- POJ 2411 Mondriaan's Dream -- 状压DP
题目:Mondriaan's Dream 链接:http://poj.org/problem?id=2411 题意:用 1*2 的瓷砖去填 n*m 的地板,问有多少种填法. 思路: 很久很久以前便做过 ...
- Poj 2411 Mondriaan's Dream(压缩矩阵DP)
一.Description Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, ...
- POJ - 2411 Mondriaan's Dream(轮廓线dp)
Mondriaan's Dream Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One nig ...
- [poj 2411]Mondriaan's Dream (状压dp)
Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 18903 Accepted: 10779 D ...
- Poj 2411 Mondriaan's Dream(状压DP)
Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Description Squares and rectangles fascina ...
- poj 2411 Mondriaan's Dream(状态压缩dP)
题目:http://poj.org/problem?id=2411 Input The input contains several test cases. Each test case is mad ...
- poj 2411 Mondriaan's Dream(状态压缩dp)
Description Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One night, af ...
- poj 2411 Mondriaan's Dream 轮廓线dp
题目链接: http://poj.org/problem?id=2411 题目意思: 给一个n*m的矩形区域,将1*2和2*1的小矩形填满方格,问一共有多少种填法. 解题思路: 用轮廓线可以过. 对每 ...
随机推荐
- [洛谷P1434] [SHOI2007]滑雪
题目链接: here we go 题外话: 谁能想到这是一道咕了两年的\(AC\)呢--当年是在搜索还半懂不懂的时候遇到的这道题,感觉真是难得要命()所以一直拖着不做,后面就下意识地逃避了搜索相关的内 ...
- AtCoder Beginner Contest 054 ABCD题
A - One Card Poker Time limit : 2sec / Memory limit : 256MB Score : 100 points Problem Statement Ali ...
- ORA-00972_标识符过长
执行SQL查询报:"ORA-00972:标识符过长"错误. 执行SQL: SELECT T.F_FTBS, T.F_TZMC "X组/XXXX/XXXX名称", ...
- linux下输出json字符串,用python格式化
echo '{"name":"chen","age":"11"}' |python -m json.tool 如果是文件 ...
- Sql Server 排序规则字符集的冲突问题
可通过如下sql 进行修改: 如果整个DB都不一致: Alter database Expense_Portal collate Chinese_PRC_CI_AS 某张Table的栏位不一致: ) ...
- SpringBoot学习笔记-Chapter2(hello word)
开篇 第一次在博客园上写博客,初衷是想记录一下学习笔记,以往都是用笔去记录下学习笔记,现在来看在效率.检索速度上以及可可复制性都不好.作为一名Java开发人员 不会Spring Boot一定会被鄙视的 ...
- 什么是OOA/OOD
Object Oriented Analyzing Object Oriented Design Object Oriented Programming ooa(object oriented ana ...
- Mysql order by 多字段排序
mysql单个字段降序排序: select * from table order by id desc; mysql单个字段升序排序: select * from table order by id ...
- CF1060D Social Circles
思路: 贪心.既然每个人的左边是其他人的右边,每个人的右边是其他人的左边,那么使重叠的部分最多即可. 实现: #include <bits/stdc++.h> using namespac ...
- 常用验证函数isset()/empty()/is_numeric()函数
1) isset()用来检查变量是否设置,若变量存在且值不为NULL时为TRUE: 检查多个变量时变量要全部存在且值不为NULL时为TRUE: 若用函数unset()释放后再用isset()检测时为F ...