POJ2411 铺地砖 Mondriaan's Dream
Time Limit: 3000MS | Memory Limit: 65536K | |
Total Submissions: 15962 | Accepted: 9237 |
Description

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
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#include<cstdio> #include<cstring> #include<algorithm> using namespace std; long long dp[13][1<<11]; int n,m; void dfs( int i, int j, int state, int next) { if (j==m) { dp[i+1][next] += dp[i][state]; return ; } if (((1<<j)&state) > 0) dfs(i,j+1,state,next); if (((1<<j)&state) == 0) dfs(i,j+1,state,next|(1<<j)); if (j<=m-2 && ((1<<j)&state) == 0 && ((1<<(j+1))&state) == 0) dfs(i,j+2,state,next); return ; } int main() { while ( scanf ( "%d%d" ,&n,&m)&&(n||m)) { if (n%2==1&&m%2==1){ printf ( "0\n" ); continue ; } if (n<m) swap(n,m); memset (dp,0, sizeof (dp)); dp[1][0] = 1; for ( int i=1;i<=n;i++) { for ( int j=0;j<(1<<m);j++) { if (dp[i][j]) dfs(i,0,j,0); } } printf ( "%lld\n" ,dp[n+1][0]); } } |
POJ2411 铺地砖 Mondriaan's Dream的更多相关文章
- 【POJ2411】Mondriaan's Dream(轮廓线DP)
[POJ2411]Mondriaan's Dream(轮廓线DP) 题面 Vjudge 题解 这题我会大力状压!!! 时间复杂度大概是\(O(2^{2n}n^2)\),设\(f[i][S]\)表示当前 ...
- 【poj2411】 Mondriaan's Dream
http://poj.org/problem?id=2411 (题目链接) 题意 一个$n*m$的网格,用$1*2$的方块填满有多少种方案. Solution 轮廓线dp板子.按格dp,对上方和左方的 ...
- 【poj2411】Mondriaan's Dream 状态压缩dp
AC传送门:http://vjudge.net/problem/POJ-2411 [题目大意] 有一个W行H列的广场,需要用1*2小砖铺盖,小砖之间互相不能重叠,问有多少种不同的铺法? [题解] 对于 ...
- 【POJ2411】Mondriaan's Dream
题目大意:给定一个 N*M 的棋盘,用 1*2 的木条填满有多少种不同的方式. 题解:在这里采用以行为阶段进行状压 dp.到第 i 行时,1*1 的木块分成两类,第一类是这个木块是竖着放置木条的上半部 ...
- POJ2411 Mondriaan's Dream(状态压缩)
Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 15295 Accepted: 882 ...
- poj2411 Mondriaan's Dream【状压DP】
Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 20822 Accepted: 117 ...
- [Poj2411]Mondriaan's Dream(状压dp)(插头dp)
Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 18096 Accepted: 103 ...
- POJ1185 炮兵阵地 和 POJ2411 Mondriaan's Dream
炮兵阵地 Language:Default 炮兵阵地 Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 34008 Accepted ...
- poj2411 Mondriaan's Dream (轮廓线dp、状压dp)
Mondriaan's Dream Time Limit: 3000MS Memory Limit: 65536K Total Submissions: 17203 Accepted: 991 ...
随机推荐
- MongoDB——待整理
MongoDB mongoose——http://mongoosejs.com/ npm i mongoose Mongoose 通过外键与另一张表建立关联:Mongoose Populate 基本使 ...
- Composer安装与使用
Composer是PHP中用来管理依赖(dependency)关系的工具.你可以在自己的项目中声明所依赖的外部工具库(libraries),Composer会帮你安装这些依赖的库文件. Windows ...
- mybatis源码分析(一)------------入门
在进行源码分析前,先写一个使用mybatis进行开发的demo,方便我们后面进行分析. 一 关于mybatis的demo pom.xml文件 <project xmlns="http ...
- Linux基础操作二
编程语言的作用及与操作系统和硬件的关系 编程语言的作用:用来定义计算机程序的形式,程序员用它来编写程序,进而控制其向计算机发出指令,使计算机完成人类布置的任务. 编程语言的作用及与操作系统和硬件的关系 ...
- 转《基于Ionic3实现微信支付和支付宝支付》
在Ionic应用里实现支付并不难,但是有的坑真是不爬不知道. 一:支付宝支付 网上关于支付宝支付cordova插件真是非常多,但是大多会报一些让你很无语的错误.比如sdk早已过时不是最新的,或者没有出 ...
- Javaweb小结之——JavaBean+持久层
数据持久层学习了JDBC.连接池以及DBUtil 思考一下,在学会使用SSM框架之前,还是先多使用DBUtil吧 数据库持久层的JDBC.连接池和DBUtil,这个链接给我了一些参考https://b ...
- css的类选择器
css的类选择形式 .类名{} 通配类选择器:*.类名{} 某种元素的类选择器:元素名.类名{} 多类选择器:<p class="css1 css2"></p& ...
- springboot+jpa+mysql+redis+swagger整合步骤
springboot+jpa+MySQL+swagger框架搭建好之上再整合redis: 在电脑上先安装redis: 一.在pom.xml中引入redis 二.在application.yml里配置r ...
- 51nod2383
2383 高维部分和 1 秒 131,072 KB 80 分 5 级题 输入一个长度为n的数组a[i],下标从0开始(0到n-1)保证n是2的整数次幂,对于每个i (0 <= i < ...
- TLS/SSL