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的更多相关文章

  1. POJ 2411 Mondriaan's Dream 插头dp

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

  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)

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

  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 (状压dp)

    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 Description Squares and rectangles fascina ...

  7. poj 2411 Mondriaan's Dream(状态压缩dP)

    题目:http://poj.org/problem?id=2411 Input The input contains several test cases. Each test case is mad ...

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

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

  9. poj 2411 Mondriaan's Dream 轮廓线dp

    题目链接: http://poj.org/problem?id=2411 题目意思: 给一个n*m的矩形区域,将1*2和2*1的小矩形填满方格,问一共有多少种填法. 解题思路: 用轮廓线可以过. 对每 ...

随机推荐

  1. 学习Mahout(三)

    开发+运行第一个Mahout的程序 代码: /** * Licensed to the Apache Software Foundation (ASF) under one or more * con ...

  2. TTM-To the moon

    传送门 查询历史版本,回到历史版本,这个题目显然是用主席树,好像就没了! 但是这里的修改是区间修改,众所周知主席树的空间复杂度是\(nlog(n)\)的,区间修改会导致主席树的开点到达一个相当恐怖的数 ...

  3. HTTP1.1规范下载由6个文档组成

  4. 基于php的AWS存储服务

    近几天用到了aws的s3存储服务,公司内部的完全兼容aws并对其进行了封装,之前也用过,现在把经验总结一下. 既然要用,首先需要安装sdk,下边提供了几种安装方法 方法一:使用composer安装 1 ...

  5. jQuery 获取标签属性值的问题

    jquery attr()无法获取属性值问题 css里明明已经设置过了: 可还是获取不了: 求指导.   一定是undefined,attr是用来获得或设置标签属性的,不是用来获得CSS属性的.如果你 ...

  6. 捕获异常try-catch-finally

    异常分类 try-carch-finally出现规则 return关键字的使用 finally中慎用return,虽然语法上没错,但是由于finally的强制执行,影响逻辑上需要return的值 pa ...

  7. PyAudio 实现录音 自动化交互实现问答

    Python 很强大其原因就是因为它庞大的三方库 , 资源是非常的丰富 , 当然也不会缺少关于音频的库 关于音频, PyAudio 这个库, 可以实现开启麦克风录音, 可以播放音频文件等等,此刻我们不 ...

  8. Codeforces 1143B(思维、技巧)

    自己水平太低,不丢人. 结论是最后选取的数后缀一定是若干个9,暴举即可.然而暴举也有暴举的艺术. ll n; ll dfs(ll n) { if (n == 0) return 1; if (n &l ...

  9. Dubbo理论知识

    本文是作者根据官方文档以及自己平时的使用情况,对 Dubbo 所做的一个总结.如果不懂 Dubbo 的使用的话,可以参考我的这篇文章<超详细,新手都能看懂 !使用SpringBoot+Dubbo ...

  10. TAIL and HEAD

    TAIL and HEAD tail tail:将指定的文件的最后部分输出到标准设备,通常是终端,和cat以及more等显示文本的差别在于:假设该档案有更新,tail会自己主动刷新,确保你看到最新的档 ...