题目链接:

http://poj.org/problem?id=2411

Mondriaan's Dream

Time Limit: 3000MS
Memory Limit: 65536K
#### 问题描述
> 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!
#### 输入
> 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 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.
####样例输入
> 1 2
> 1 3
> 1 4
> 2 2
> 2 3
> 2 4
> 2 11
> 4 11
> 0 0
>
####样例输出
> 1
> 0
> 1
> 2
> 3
> 5
> 144
> 51205

题意

1*22*1的骨牌排满n*m的方格。

题解

插头dp入门题

参考:port

#include<map>
#include<set>
#include<cmath>
#include<queue>
#include<stack>
#include<ctime>
#include<vector>
#include<cstdio>
#include<string>
#include<bitset>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std;
#define X first
#define Y second
#define mkp make_pair
#define lson (o<<1)
#define rson ((o<<1)|1)
#define mid (l+(r-l)/2)
#define sz() size()
#define pb(v) push_back(v)
#define all(o) (o).begin(),(o).end()
#define clr(a,v) memset(a,v,sizeof(a))
#define bug(a) cout<<#a<<" = "<<a<<endl
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define scf scanf
#define prf printf typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
typedef vector<pair<int,int> > VPII; const int INF=0x3f3f3f3f;
const LL INFL=0x3f3f3f3f3f3f3f3fLL;
const double eps=1e-9; const double PI = acos(-1.0); //start---------------------------------------------------------------------- const int maxn=13;
LL dp[2][1<<maxn];
int n,m; int main() {
while(scf("%d%d",&n,&m)==2&&n){
if(n<m) swap(n,m); int pre=0,cur=1;
clr(dp[cur],0);
dp[cur][0]=1; for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
swap(pre,cur);
clr(dp[cur],0); int p1=(1<<j),p2=(1<<(j+1)); for(int k0=0;k0<(1<<(m+1));k0++){
int k=k0;
///注意!换行的时候的处理
if(!j) k=k0<<1; if((p1&k)&&!(p2&k)){
dp[cur][k^p1]+=dp[pre][k0];
}else if(!(p1&k)&&(p2&k)){
dp[cur][k^p2]+=dp[pre][k0];
}else if(!(p1&k)&&!(p2&k)){
if(j<m-1) dp[cur][k^p2]+=dp[pre][k0];
if(i<n-1) dp[cur][k^p1]+=dp[pre][k0];
}
}
} } prf("%lld\n",dp[cur][0]); }
return 0;
} //end-----------------------------------------------------------------------

POJ 2411 Mondriaan's Dream 插头dp的更多相关文章

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

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

  2. POJ 2411 Mondriaan's Dream ——状压DP 插头DP

    [题目分析] 用1*2的牌铺满n*m的格子. 刚开始用到动规想写一个n*m*2^m,写了半天才知道会有重复的情况. So Sad. 然后想到数据范围这么小,爆搜好了.于是把每一种状态对应的转移都搜了出 ...

  3. POJ 2411 Mondriaan's Dream -- 状压DP

    题目:Mondriaan's Dream 链接:http://poj.org/problem?id=2411 题意:用 1*2 的瓷砖去填 n*m 的地板,问有多少种填法. 思路: 很久很久以前便做过 ...

  4. Poj 2411 Mondriaan's Dream(压缩矩阵DP)

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

  5. POJ - 2411 Mondriaan's Dream(轮廓线dp)

    Mondriaan's Dream Squares and rectangles fascinated the famous Dutch painter Piet Mondriaan. One nig ...

  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)

    Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 18903 Accepted: 10779 D ...

  8. [POJ] 2411 Mondriaan's Dream

    Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 18903 Accepted: 10779 D ...

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

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

随机推荐

  1. Struts2知识点小结(一)

    一.struts2简介 1.Struts2是一个基于MVC设计模式的Web应用框架        只要是web层框架 一般就会遵守MVC设计模式     2.struts2与struts1的关系?  ...

  2. jQuery的一点小结

    1.jQuery常用选择器 筛选: $('div').has('p'); // 选择包含p元素的div元素 $('div').not('.myClass'); //选择class不等于myClass的 ...

  3. JavaWeb基础—HttpServletResponse

    HttpServletResponse对象代表服务器的响应. 这个对象中封装了向客户端发送数据.发送响应头,发送响应状态码的方法. 几个方法: 向客户端发送数据: getOutputStream() ...

  4. vue打包完样式冲突

    在页面的<style> 后,加上scoped, 例: scoped是实现样式的私有化,使样式不容易被覆盖,不容易被修改,只对当前页面有效

  5. 2017战略No.1:坚定不移地走全产业链发展路线

    编者按:2016年9月9日,首次公开表达"我想走全产业链发展路线"的想法. 这几个月,认真思考了下这个决定背后的原因.目的和价值. 付出常人5倍以上的努力,先抓住"技术研 ...

  6. Tarjan/2-SAT学习笔记

    Tarjan/2-SAT Tags:图论 作业部落 评论地址 Tarjan 用来求割边或者割点,求点双联通分量或者边双联通分量 点双联通分量:两个点之间有两条点不相交的路径 边双联通分量:两个点之间有 ...

  7. Oracle保存带&的数据

    在SQL*Plus中默认的"&"表示替代变量,也就是说,只要在命令中出现该符号,SQL*Plus就会要你输入替代值.这就意味着你无法将一个含有该符号的字符串输入数据库或赋给 ...

  8. 日常的例子说明 throttle 和 debounce 的区别

    不小心接触到 throttle 和 debounce,按捺不住猎奇的心理,找这两个函数的资料. 然而百度到的各种对他们的理解,我去啊. 艰难地搞明白他们是干嘛的之后,忍不住举个例子说说自己的理解,希望 ...

  9. .net 分布式学习计划

    一: 1:.net分布式系统架构的思路     https://blog.csdn.net/slowlifes/article/details/53162014 2: nginx+iis实现负载均衡 ...

  10. 大神教你零基础学PS,30堂课从入门到精通

    ps视频教程,ps自学视频教程.ps免费视频教程下载,大神教你零基础学PS教程视频内容较大,分为俩部分: 大神教你零基础学PS--30堂课从入门到精通第一部分:百度网盘,https://pan.bai ...