您的位置:首页 > 产品设计 > UI/UE

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

.



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);
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: