hdu 5301Buildings 2015 Multi-University Training Contest 2
2015-07-23 21:15
681 查看
Buildings
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 568 Accepted Submission(s): 133
Problem Description
Your current task is to make a ground plan for a residential building located in HZXJHS. So you must determine a way to split the floor building with walls to make apartments in the shape of a rectangle. Each built wall must be paralled
to the building's sides.
The floor is represented in the ground plan as a large rectangle with dimensions
n×m
,
where each apartment is a smaller rectangle with dimensions
a×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×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
.
![](https://oscdn.geek-share.com/Uploads/Images/Content/201706/0b6e457f8faf4183ae8a8f347e6afb76.jpg)
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.
Input
There are at most 10000
testcases.
For each testcase, only four space-separated integers,
n,m,x,y(1≤n,m≤10
8
,n×m>1,1≤x≤n,1≤y≤m)
.
Output
For each testcase, print only one interger, representing the answer.
Sample Input
2 3 2 2 3 3 1 1
Sample Output
1 2 Hint Case 1 :You can split the floor into five 1×1
apartments. The answer is 1. Case 2:
You can split the floor into three 2×1
apartments and two 1×1
apartments. The answer is 2.
If you want to split the floor into eight 1×1
apartments, it will be unacceptable because the apartment located on (2,2) can't have windows.
Source
2015 Multi-University Training Contest 2
Recommend
wange2014 | We have carefully selected several similar problems for you: 5309 5308 5307 5306 5305
题意:要求每个格子一个或连续多个连成的矩型(不能经过X格子)都要与边框相连,求分配好所有的格子后矩形面积最大中的最小值是多少。
解题:首先判断最中间的格子,再判断与X格子的四条相邻的格子。
#include<stdio.h> #include<algorithm> using namespace std; int main() { int n,m,x,y; while(scanf("%d%d%d%d",&n,&m,&x,&y)>0) { int ans=0; int mint=min(n,m); if(n%2&&m%2) { ans=mint/2+1; if(x==(n+1)/2&&y==(m+1)/2&&n==m) ans-=1; else{ int tx,ty,tans[4]; tx=x+1;ty=y; tans[0]=n-tx+1; tans[0]=min(tans[0],min(ty,m-ty+1)); tx=x-1;ty=y; tans[1]=tx; tans[1]=min(tans[1],min(ty,m-ty+1)); tx=x;ty=y+1; tans[2]=tx; tans[2]=min(tans[2],min(n-tx+1,m-ty+1)); tx=x;ty=y-1; tans[3]=tx; tans[3]=min(tans[3],min(n-tx+1,ty)); tans[0]=max(tans[0],max(tans[1],tans[2])); tans[0]=max(tans[0],tans[3]); ans=max(ans,tans[0]); } } else{ ans=(mint+1)/2; int tx,ty,tans[4]; tx=x+1;ty=y; tans[0]=n-tx+1; tans[0]=min(tans[0],min(ty,m-ty+1)); tx=x-1;ty=y; tans[1]=tx; tans[1]=min(tans[1],min(ty,m-ty+1)); tx=x;ty=y+1; tans[2]=tx; tans[2]=min(tans[2],min(n-tx+1,m-ty+1)); tx=x;ty=y-1; tans[3]=tx; tans[3]=min(tans[3],min(n-tx+1,ty)); tans[0]=max(tans[0],max(tans[1],tans[2])); tans[0]=max(tans[0],tans[3]); ans=max(ans,tans[0]); } printf("%d\n",ans); } }
相关文章推荐
- 最长公共子序列(dp) & hdu 1159 Common Subsequence
- 数学 HDOJ 5301 Buildings
- hdu5301(2015多校2)--Buildings(构造)
- 【分享】UIViewController生命周期简单归纳
- Arduino Wire.h 库函数基本操作 IIC
- Frequently used algorithms in Leetcode
- 【Espruino】NO.06 关键是你的仆人(继续)
- Snail—UI学习之自定义键盘及键盘收起(待完善)
- IOS--UI--LessonNetWork
- 04-UIScrollView分页功能实现循环查看图片
- IOS-UITextField-邮箱后缀联想赛
- 每天一个小知识点11(jQuerMobile总结二)
- OC07 -- 迭代器/NSNumber/NSValue/NSRange/NSSet/NSDate 及相互转换.(杂)
- Snail—UI学习之UITextField
- STL 整理(map、set、vector、list、stack、queue、deque、priority_queue)(转)
- 【Android UI】自定义Switch(无滑动效果)
- HDU5288 OO’s Sequence(序列的整除对数计数) 多校赛1最水题
- Dijkstra with priority queue
- Dijkstra with priority queue 分类: ACM TYPE 2015-07-23 20:12 4人阅读 评论(0) 收藏
- CF560D Equivalent Strings 可拆分的字符串是否等价