POJ - 2411 Mondriaan's Dream(轮廓线dp)
Mondriaan's Dream
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
Output
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 题意:给出行列n,m,求用1*2的瓷砖铺满的方案数。 将当前行与上一行的情况预处理出来,
ps:行列全为奇一定是0,一点优化可以将大数作行,小数作列。
第一行和最后一行一定全为1,最后从第一行到最后一行递推即可。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#define MAX 12
using namespace std;
typedef long long ll; struct Node{
int pre,now;
}node;
vector<Node> v;
ll dp[MAX][<<]; int n,m;
void dfs(int x,int pre,int now){
if(x>m) return;
if(x==m){
node.pre=pre;
node.now=now;
v.push_back(node);
return;
}
dfs(x+,(pre<<)|,(now<<)|); //横放
dfs(x+,pre<<,(now<<)|); //竖放
dfs(x+,(pre<<)|,now<<); //不放
}
int main()
{
int i,j;
while(scanf("%d%d",&n,&m)&&n+m){
if((n*m)&){
printf("0\n");
continue;
}
if(n<m){
int t=n;n=m;m=t;
}
v.clear();
dfs(,,);
memset(dp,,sizeof(dp));
dp[][(<<m)-]=;
for(i=;i<=n;i++){
for(j=;j<v.size();j++){
dp[i][v[j].now]+=dp[i-][v[j].pre];
}
}
printf("%lld\n",dp[n][(<<m)-]);
}
return ;
}
POJ - 2411 Mondriaan's Dream(轮廓线dp)的更多相关文章
- poj 2411 Mondriaan's Dream 轮廓线dp
题目链接: http://poj.org/problem?id=2411 题目意思: 给一个n*m的矩形区域,将1*2和2*1的小矩形填满方格,问一共有多少种填法. 解题思路: 用轮廓线可以过. 对每 ...
- 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 Time Limit: 3000MS Memory Limit: 65536K Description Squares and rectangles fascina ...
- [poj 2411]Mondriaan's Dream (状压dp)
Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 18903 Accepted: 10779 D ...
- Mondriaan's Dream 轮廓线DP 状压
Mondriaan's Dream 题目链接 Problem Description Squares and rectangles fascinated the famous Dutch painte ...
- [POJ] 2411 Mondriaan's Dream
Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 18903 Accepted: 10779 D ...
- POJ2411 Mondriaan's Dream 轮廓线dp
第一道轮廓线dp,因为不会轮廓线dp我们在南京区域赛的时候没有拿到银,可见知识点的欠缺是我薄弱的环节. 题目就是要你用1*2的多米诺骨排填充一个大小n*m(n,m<=11)的棋盘,问填满它有多少 ...
随机推荐
- The template root requires exactly one element
The template root requires exactly one element
- php中$t=date()函数参数意义及时间更改
php中date()函数用的最多的是:date('Y-m-d H:i:s', time()); 这里面的参数意义分别是:Y - 年,四位数字; 如: "2016":m - 月份, ...
- [持续集成]Jenkins 自动化部署 Maven 工程
一.Jenkins 持续部署原理图 基础服务: 1 SVN 服务 SVN是Subversion的简称,是一个开放源代码的版本控制系统.说得简单一点SVN就是用于多个人共同开发同一个项目,共用资源的目的 ...
- .net编程扫盲(*)
http://www.cnblogs.com/edisonchou/p/4787775.html
- Pandas一些小技巧
Pandas有一些不频繁使用容易忘记的小技巧 1.将不同Dataframe写在一个Excel的不同Sheet,或添加到已有Excel的不同Sheet(同名Sheet会覆盖) from pandas i ...
- P3715 [BJOI2017]魔法咒语
P3715 [BJOI2017]魔法咒语 用基本词汇组成\(L\)长度的单词,其中不能包含禁忌词汇 用禁忌词汇建强大的\(tire\)图 解决: 分类讨论,\(L<=100\)用普通dp暴力在\ ...
- Dictionary and KeyValuePair关系
简单一句话: Dictionary 是 由 KeyValuePair结构 组成的集合 The Dictionary<TKey, TValue>.Enumerator.Current pro ...
- joomla搬家之后打不开 首页404错误
joomla 安装好之后, 网站打不开,首页404错误,后台能够正常访问,数据库连接正常.应该是 nginx配置的问题.该如何修改配置呢?随便一个链接点进去都是404,找不到页面,URL的形式如下: ...
- haproxy 修改 访问路径
# 匹配 jsessionid,并去除 jessionid参数reqrep ^([^\ :]*)\ /a/test.html;jsessionid=.*\?(.*) \1\ /b/test.html? ...
- dead reckoning variation
Targeting A target is a structure of information that describes the state, and change of state, of a ...