2015 Multi-University Training Contest 2 Buildings

Buildings

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 804    Accepted Submission(s): 222


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.

2015 Multi-University Training Contest 2 Buildings


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(1n,m108,n×m>1,1xn,1ym).
 

 

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 :
2015 Multi-University Training Contest 2 Buildings
You can split the floor into five 1×1 apartments. The answer is 1. Case 2:
2015 Multi-University Training Contest 2 Buildings
You can split the floor into three 2×1 apartments and two 1×1 apartments. The answer is 2.
2015 Multi-University Training Contest 2 Buildings
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
 

 解题:。。。。反正可以分成1*x的形状,所以只要最长边最短即可。当x < ret 时 影响最大的应该是下部分 黑块下的那小块怎么让他拥有窗户

可以选择拥有左边 可以选择下边 可以选择右边 取最小就是了,其余的部分 最大莫过于ret了。。。

x > ret时 是上部分 同理

 

 

2015 Multi-University Training Contest 2 Buildings
 1 #include <bits/stdc++.h>

 2 using namespace std;

 3 int main(){

 4     int n,m,x,y;

 5     while(~scanf("%d%d%d%d",&n,&m,&x,&y)){

 6         int ret = (min(n,m)+1)>>1;

 7         if(n > m) {swap(n,m);swap(x,y);}

 8         if((n&1) && n == m && y == ret && x == ret) --ret;

 9         if(x < ret) ret = max(ret,min(n-x,min(y,m-y+1)));

10         else if(x > ret) ret = max(ret,min(x-1,min(y,m-y+1)));

11         printf("%d\n",ret);

12     }

13     return 0;

14 }
View Code

 

你可能感兴趣的:(Build)