hdu5301(2015多校2)--Buildings(构造)
Buildings
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 472 Accepted Submission(s): 104
The floor is represented in the ground plan as a large rectangle with dimensions $n \times m$, where each apartment is a smaller rectangle with dimensions $a\times b$ located inside. For each apartment, its dimensions can be different from each other. The number
$a$ and $b$ must be integers.
Additionally, the apartments must completely cover the floor without one $1 \times 1$ square located on $(x,y)$. The apartments must not intersect, but they can touch.
For this example, this is a sample of $n=2,m=3,x=2,y=2$.

To prevent darkness indoors, the apartments must have windows. Therefore, each apartment must share its at least one side with the edge of the rectangle representing the floor so it is possible to place a window.
Your boss XXY wants to minimize the maximum areas of all apartments, now it's your turn to tell him the answer.
For each testcase, only four space-separated integers, $n,m,x,y(1\leq n,m \leq 10^8,n\times m > 1, 1\leq x \leq n, 1 \leq y \leq m)$.
2 3 2 2
3 3 1 1
1
2HintCase 1 :
You can split the floor into five $1 \times 1$ apartments. The answer is 1. Case 2:
You can split the floor into three $2 \times 1$ apartments and two $1\times 1$ apartments. The answer is 2.
If you want to split the floor into eight $1 \times 1$ apartments, it will be unacceptable because the apartment located on (2,2) can't have windows.
题目大意:有n*m的一个矩形地面,要建公寓,如今要求公寓里的房间怎么划分。要求每间房屋都为一个矩形。并且要有一側为矩形的边,除(x,y)位置外不能有空余,(x,y)位置不能建房间,要让房屋面积最大的那个的面积尽量的小。问最小会是多少
如图,黑色的是(x,y)。那么它的上下两块仅仅可被有三个边的某一个覆盖掉,为了让最大的面积最小。要让宽为1。长为三边到空白方格的最小值,还有除了黑色部分的多于部分,要让他们被覆盖掉。能够用上下两条边来建房屋高为(m+1)/2,找出最大的。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;
int main() {
int n , m , x , y , ans , min1 , min2 ;
while( scanf("%d %d %d %d", &n, &m, &x, &y) != EOF ) {
if( n > m ) {
swap(n,m) ;
swap(x,y) ;
}
if( n == 1 ) {
printf("1\n") ;
continue ;
}
min1 = min(x-1,min(y,m-y+1)) ;
min2 = min(n-x,min(y,m-y+1)) ;
ans = (n+1)/2 ;
if( n == m && n%2 && ans == x && ans == y )
ans-- ;
printf("%d\n", max(ans,max(min1,min2) )) ;
}
return 0 ;
}
hdu5301(2015多校2)--Buildings(构造)的更多相关文章
- hdu 5288||2015多校联合第一场1001题
pid=5288">http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a ar ...
- hdu5379||2015多校联合第7场1011 树形统计
pid=5379">http://acm.hdu.edu.cn/showproblem.php? pid=5379 Problem Description Little sun is ...
- 2015 多校联赛 ——HDU5334(构造)
Virtual Participation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Ot ...
- 2015 多校联赛 ——HDU5302(构造)
Connect the Graph Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- HDU 5301 Buildings(2015多校第二场)
Buildings Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Tota ...
- 2015多校联合训练赛 hdu 5308 I Wanna Become A 24-Point Master 2015 Multi-University Training Contest 2 构造题
I Wanna Become A 24-Point Master Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 ...
- 2015多校联合训练赛hdu 5301 Buildings 2015 Multi-University Training Contest 2 简单题
Buildings Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Tota ...
- 2015多校.MZL's endless loop(欧拉回路的机智应用 || 构造)
MZL's endless loop Time Limit: 3000/1500 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Oth ...
- 2015 多校联赛 ——HDU5301(技巧)
Your current task is to make a ground plan for a residential building located in HZXJHS. So you must ...
随机推荐
- hdoj--1342--Lotto(dfs)
Lotto Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Subm ...
- Java读取txt文件和覆盖写入txt文件和追加写入txt
//创建文件 public static void createFile(File filename) { try { if(!filename.exists()) { filename.create ...
- JavaScript笔记(4)
接上一篇笔记 -----> 打印: 打印: 打印: 一.break 和 continue 的区别 1.break 1.break语句可用于跳出循 ...
- CSS2.1(布局)
浏览器内核 Firefox : geckoIE: tirdentSafari: webkitChrome: 一开始使用webkit 后来基于webkit开发了Blinkopera: 一开始使用pres ...
- 学习《TensorFlow实战Google深度学习框架 (第2版) 》中文PDF和代码
TensorFlow是谷歌2015年开源的主流深度学习框架,目前已得到广泛应用.<TensorFlow:实战Google深度学习框架(第2版)>为TensorFlow入门参考书,帮助快速. ...
- 研究一些复杂java开源软件代码的体会(转)
原文地址:http://herman-liu76.iteye.com/blog/2349026 有时候看源代码是非常有趣的事情,象是思考游戏,象是思考棋局... 平时做J2EE项目中, ...
- Linux中去除windows文件中的控制字符
Windows下的文本文件拿到Linux下时,会在文本行最后面出现很多字符:^M Linux下去除掉的方法是:dos2unix file(需要软件包dos2unix) 当然逆转的方法为unix2dos ...
- [Python] Python list slice syntax fun
# Python's list slice syntax can be used without indices # for a few fun and useful things: # You ca ...
- Nginx+tomcat+ssl免费证书配置
0.说明 本文说描写叙述的方式是用nginx的443重定向到tomcat的8443,nginx的80port重定到tomcat的8080: 乱入:个人标记:caicongyang 1.nginx安装 ...
- HTTP请求和响应1:概述
HTTP的报文分为请求报文和响应报文,打开一个web页面后,浏览器将发起一个HTTP请求报文.HTTPserver收到请求后将回送一个响应报文. 报文的基本结构 HTTP的请求和响应报文都由三个部分组 ...