Mondriaan's Dream POJ - 2411
可以用状压dp,但是要打一下表。暴力枚举行、这一行的状态、上一行的状态,判断如果上一行的状态能转移到这一行的状态就转移。
状态定义:ans[i][S]表示i行前已经全部填满,i行已经填上的列为集合S。如果有竖着的,全部当做用这一行的去补满上一行缺的。
(貌似还是插头dp的入门题)
#include<cstdio>
#include<cstring>
typedef long long LL;
LL f[][];
LL h,w;
/*LL ans[12][2050];
LL h,w;
bool judge(LL a,LL b)
{
LL i,num=0,t1,t2;
for(i=1;i<=w;i++)
{
t1=a&1;
t2=b&1;
a>>=1;
b>>=1;
if(t1==1&&t2==1)
num++;
else if(t1==0&&t2==0)
return false;
else
{
if(num&1)
return false;
num=0;
}
}
if(num&1)
return false;
else
return true;
}
LL get(LL h,LL w)
{
LL i,j,k;
memset(ans,0,sizeof(ans));
ans[0][(1<<w)-1]=1;
for(i=1;i<=h;i++)
for(j=0;j<(1<<w);j++)
for(k=0;k<(1<<w);k++)
if(judge(k,j))
{
ans[i][j]+=ans[i-1][k];
}
return ans[h][(1<<w)-1];
}
int main()
{
for(h=1;h<=11;h++)
for(w=1;w<=11;w++)
printf("f[%lld][%lld]=%lld;\n",h,w,get(h,w));
return 0;
}*/
int main()
{
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
f[][]=;
scanf("%lld%lld",&h,&w);
while(h!=&&w!=)
{
printf("%lld\n",f[h][w]);
scanf("%lld%lld",&h,&w);
}
}
Mondriaan's Dream POJ - 2411的更多相关文章
- Mondriaan's Dream(POJ 2411状态压缩dp)
题意:用1*2的方格填充m*n的方格不能重叠,问有多少种填充方法 分析:dp[i][j]表示i行状态为j时的方案数,对于j,0表示该列竖放(影响下一行的该列),1表示横放成功(影响下一列)或上一列竖放 ...
- Mondriaan's Dream - POJ 2411(状态压缩)
题目大意:有一些1*2的矩形,现在用这些小矩形覆盖M*N的大矩形,不能重复覆盖,并且要覆盖完全,求有多少种覆盖方式. 分析:可以使用1和0两种状态来表示这个位置有没有放置,1表示放置,0表示没有放置, ...
- poj 2411 Mondriaan's Dream 【dp】
题目:id=2411" target="_blank">poj 2411 Mondriaan's Dream 题意:给出一个n*m的矩阵,让你用1*2的矩阵铺满,然 ...
- 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
题目链接: http://poj.org/problem?id=2411 Mondriaan's Dream Time Limit: 3000MSMemory Limit: 65536K 问题描述 S ...
- 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 Total Submissions: 13519 Accepted: 787 ...
- POJ 2411 Mondriaan's Dream
状压DP Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 9938 Accepted: 575 ...
- HDU 1400 (POJ 2411 ZOJ 1100)Mondriaan's Dream(DP + 状态压缩)
Mondriaan's Dream Problem Description Squares and rectangles fascinated the famous Dutch painter Pie ...
随机推荐
- [NPM] Create a new project using the npm init <initializer> command
Historically, the npm init command was solely use to create a new package.json file. However, as of ...
- Java中常见的排序算法
这是我摘取的一段英文资料.我认为学习算法之前,对各种排序得有个大致的了解: Sorting algorithms are an important part of managing data. At ...
- 【Mongodb教程 第一课补加课2 】MongoDB下,启动服务时,出现“服务没有响应控制功能”解决方法
如图,如果通过下列代码,添加服务后,使用net start命令出现这样的问题时,可以参考下我的解决方法. D:\MongoDB>mongod --dbpath D:\MongoDB\Data - ...
- C#结构类型图
C#结构类型图 分类: C#
- 《modern operating system》 chapter 6 DEADLOCKS 笔记
DEADLOCKS Both processes are blocked and will remain so forever. This situation is called a deadlock ...
- Ios 项目从头开发 MVVM模式(三)
1.话说,本来想做个聚合查询功能.可是我的重点想研究xmpp聊天功能.所以使用mvvm模式做了全然模式51job主界面的页面. 2.首先给大家看我执行起来的界面. 3.界面非常easy,做这个界面主要 ...
- 2016/05/13 Thinkphp 3.2.2 ①数据添加 ②收集表单数据入库操作 ③数据修改操作
①数据查询 add() 该方法返回被添加的新记录的主键id值 两种方式实现数据添加 数组方式数据添加 $goods = D(“Goods”); $arr = array(‘goods_name’=&g ...
- 在myeclipse下面创建多层包
比如animal.cat.dog包 先创建animal包 然后创建animal.cat包 最后创建animal.cat.dog包 最后你发现这三个文件夹是分层的,层层嵌套的三个文件夹,而不是一个文件夹 ...
- 契约式设计 契约式编程 Design by contract
Design by contract - Wikipedia https://en.wikipedia.org/wiki/Design_by_contract What is the use of & ...
- java语法基础(四)
继承 继承概述 继承是面向对象语言的三大基本特性(封装,继承,多态)之一. 一个类可以继承另外一个类,继承的类称为子类(也可以叫派生类),被继承的类称为父类(或者也叫基类,超类). 通过继承,子类可以 ...