POJ 1609 Tiling Up Blocks
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 4675 | Accepted: 1824 |
Description
Each tiling block is associated with two parameters (l,m), meaning that the upper face of the block is packed with l protruding knobs on the left and m protruding knobs on the middle. Correspondingly, the bottom face of an (l,m)-block is carved with l caving dens on the left and m dens on the middle.
It is easily seen that an (l,m)-block can be tiled upon another (l,m)-block. However,this is not the only way for us to tile up the blocks. Actually, an (l,m)-block can be tiled upon another (l',m')-block if and only if l >= l' and m >= m'.
Now the puzzle that Michael wants to solve is to decide what is the tallest tiling blocks he can make out of the given n blocks within his game box. In other words, you are given a collection of n blocks B = {b1, b2, . . . , bn} and each block bi is associated with two parameters (li,mi). The objective of the problem is to decide the number of tallest tiling blocks made from B.
Input
Note that n can be as large as 10000 and li and mi are in the range from 1 to 100.
An integer n = 0 (zero) signifies the end of input.
Output
outputs.
Sample Input
3
3 2
1 1
2 3
5
4 2
2 4
3 3
1 1
5 5
0
Sample Output
2
3
*
题目大意:给定n个砖块的长和宽,只有当x2>=x1&&y2>=y1时 n2可以放在n1上 问最高能落多高。
解题方法:求最大不上升子序列,用动态规划。
#include <stdio.h>
#include <iostream>
#include <string.h>
using namespace std; int main()
{
int w[][];
int dp[][];
int n;
while(scanf("%d", &n) != EOF)
{
if (n == )
{
printf("*\n");
break;
}
int a, b;
memset(w, , sizeof(w));
memset(dp, , sizeof(dp));
for (int i = ; i <= n; i++)
{
scanf("%d%d", &a, &b);
w[a][b]++;
}
for (int i = ; i <= ; i++)
{
for (int j = ; j <= ; j++)
{
dp[i][j] = max(dp[i - ][j], dp[i][j - ]) + w[i][j];
}
}
printf("%d\n", dp[][]);
}
return ;
}
POJ 1609 Tiling Up Blocks的更多相关文章
- poj 1609 dp
题目链接:http://poj.org/problem?id=1609 #include <cstdio> #include <cstring> #include <io ...
- poj 2506 Tiling(递推 大数)
题目:http://poj.org/problem?id=2506 题解:f[n]=f[n-2]*2+f[n-1],主要是大数的相加; 以前做过了的 #include<stdio.h> # ...
- POJ 1052 Plato's Blocks
Plato's Blocks Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 734 Accepted: 296 De ...
- [ACM] POJ 2506 Tiling (递归,睑板)
Tiling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7487 Accepted: 3661 Descriptio ...
- POJ 2506 Tiling
Tiling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7437 Accepted: 3635 Descriptio ...
- poj 2506 Tiling(高精度)
Description In how many ways can you tile a 2xn rectangle by 2x1 or 2x2 tiles? Here is a sample tili ...
- HOJ 2124 &POJ 2663Tri Tiling(动态规划)
Tri Tiling Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 9016 Accepted: 4684 Descriptio ...
- POJ 2506 Tiling(递推+大整数加法)
http://poj.org/problem?id=2506 题意: 思路:递推.a[i]=a[i-1]+2*a[i-2]. 计算的时候是大整数加法.错了好久,忘记考虑1了...晕倒. #includ ...
- poj 2506 Tiling(java解法)
题目链接:id=2506">http://poj.org/problem?id=2506 本题用的java解的.由于涉及到大数问题,假设对java中的大数操作不熟悉请点这儿:链接 思路 ...
随机推荐
- 64位Windows系统下32位应用程序连接MySql
1.首先得安装“Connector/ODBC”,就是Mysql的ODBC驱动,这个是与应用程序相关的,而不是与操作系统相关的,也就是说,不管你的系统是x64还是x86,只要你的应用程序是x86的那么, ...
- Web端 年月日下拉表 密码判断 按钮判断是否提交
生日: <asp:DropDownList ID="selYear" runat="server"></asp:DropDownList> ...
- CF 55D Beautiful numbers (数位DP)
题意: 如果一个正整数能被其所有位上的数字整除,则称其为Beautiful number,问区间[L,R]共有多少个Beautiful number?(1<=L<=R<=9*1018 ...
- 洛谷 P1433 吃奶酪
题目描述 房间里放着n块奶酪.一只小老鼠要把它们都吃掉,问至少要跑多少距离?老鼠一开始在(0,0)点处. 输入输出格式 输入格式: 第一行一个数n (n<=15) 接下来每行2个实数,表示第i块 ...
- 3. Netbackup 7.6客户端的安装(windows/linux)
1 客户端的安装 1.1 Windows客户端安装 1.1.1 客户端hosts修改 windows xp/2003/vista/2008/7/8用户HOSTS文件是在“c:\windows\syst ...
- JAVA并发编程:相关概念及VOLATILE关键字解析
一.内存模型的相关概念 由于计算机在执行程序时都是在CPU中运行,临时数据存在主存即物理内存,数据的读取和写入都要和内存交互,CPU的运行速度远远快于内存,会大大降低程序执行的速度,于是就有了高速缓存 ...
- StatementHandler-Mybatis源码系列
内容更新github地址:我飞 StatementHandler接口 StatementHandler封装了Mybatis连接数据库操作最基础的部分.因为,无论怎么封装,最终我们都是要使用JDBC和数 ...
- 面向对象OONo.3单元总结
一,JML语言 1)JML理论基础:JML是一类语言,用来描述一个方法或一个类的功能.以及这个类在实现这个功能时需要的条件.可能改变的全局变量.以及由于条件问题不能实现功能时这个方法或类的行为,具有明 ...
- 【转】C++后台开发应该读的书
转载自http://www.cnblogs.com/balloonwj/articles/9094905.html 作者 左雪菲 根据我的经验来谈一谈,先介绍一下我的情况,坐标上海,后台开发(也带团队 ...
- 【卡常 bitset 分块】loj#6499. 「雅礼集训 2018 Day2」颜色
好不容易算着块大小,裸的分块才能过随机极限数据:然而这题在线的数据都竟然是构造的…… 题目描述 有 $n$ 个数字,第 $i$ 个数字为 $a_i$. 有 $m$ 次询问,每次给出 $k_i$ 个区间 ...