[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的小矩形填满方格,问一共有多少种填法. 解题思路: 用轮廓线可以过. 对每 ...
随机推荐
- python 之 函数 迭代器
5.9 迭代器 5.91 可迭代对象和迭代器对象 1.什么是迭代?:迭代是一个重复的过程,并且每次重复都是基于上一次的结果而来 2.要想了解迭代器到底是什么?必须先了解一个概念,即什么是可迭代的对象? ...
- PAT甲级——1131 Subway Map (30 分)
可以转到我的CSDN查看同样的文章https://blog.csdn.net/weixin_44385565/article/details/89003683 1131 Subway Map (30 ...
- canvas常用画法整理
代码Canvas.htm <!DOCTYPE html> <html lang="en"> <head> <title>canvas ...
- mongodb javaapi网页版链接
http://www.open-open.com/doc/view/abe58dc8d0114ef2bd34d0bbccd3691e
- 转 造成ORA-01843 无效的月份的一些原因
- code与const void*指针
关于指针: 当定义int *p时,它也会在内存中给指针变量p分配一个内存单元,假设这个单元在内存的编址为0x1003:此时,0x1003中的值是不确定的,(因为我们没有给指针赋值),当编译器遇到了p= ...
- nodejs学习(3) express+socket.io
//node var express=require('express'); var app = express(); var server = require('http').createServe ...
- D - 連結 / Connectivity 并查集
http://abc049.contest.atcoder.jp/tasks/arc065_b 一开始做这题的时候,就直接蒙逼了,n是2e5,如果真的要算出每一个节点u能否到达任意一个节点i,这不是f ...
- Ubuntu安装LAMP
1.安装apache2 sudo apt-get install apache2 sudo apt-get install apache2 Apache安装成功后,/var/www/默认作为web的根 ...
- npm 修改源地址
修改源地址为淘宝 NPM 镜像 npm config set registry http://registry.npm.taobao.org/ 修改源地址为官方源 npm config set reg ...