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. ReenTrantLock可重入锁和synchronized的区别

    ReenTrantLock可重入锁和synchronized的区别 可重入性: 从名字上理解,ReenTrantLock的字面意思就是再进入的锁,其实synchronized关键字所使用的锁也是可重入 ...

  2. ionic4+angular7+cordova开发入门

    前言 ionic是一个垮平台开发框架,可通过web技术开发出多平台的应用.但只建议开发简单应用.复杂的应用需要用到许多cordova插件,而cordova插件的更新或者移动平台的更新很可能导致插件的不 ...

  3. 从MySQL高可用引出对高可用架构设计的一些思考

    高可用HA(High Availability)是分布式系统架构设计中必须考虑的因素之一,它通常是指,通过设计减少系统不能提供服务的时间. 假设系统一直能够提供服务,我们说系统的可用性是100%.如果 ...

  4. python+unittest 搭建简易的接口测试框架

    主要介绍如何使用python+unittest快速搭建一个接口测试的框架 1.安装python  unittest 2.新建一个python项目ApiTest 在setUp和setDown里设置一些需 ...

  5. C 语言实例 - 计算字符串长度

    C 语言实例 - 计算字符串长度 C 语言实例 C 语言实例 计算字符串长度. 实例 - 使用 strlen() #include <stdio.h> #include <strin ...

  6. python快排

    代码: def partition(data,left,right): tmp = data[left] while left<right: while left < right and ...

  7. 在 Linux 环境直接复移动硬盘上的 GRUB

    手头有一块用了 10 年的旧移动硬盘,其中安装了 Debian 系统,从低版本一直升级到现在的 9 已经用了很长时间.前不久正连着那块硬盘跑着 Debian 修改文件的时候,由于一个本可避免的意外震动 ...

  8. 云服务中IaaS、PaaS、SaaS的区别

    越来越多的软件,开始采用云服务. 云服务只是一个统称,可以分成三大类. IaaS:基础设施服务,Infrastructure-as-a-service PaaS:平台服务,Platform-as-a- ...

  9. [未读]angularjs权威教程

    正在啃,赶脚不错...

  10. 顾问Advisor Aspectj注解

    顾问Advisor  通知 advice PointcutAdvisor  一个接口  是顾问的一种. . 任意单个字符 + 重复1到多次 * 重复0到多次 NameMetchMethodPointc ...