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

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 \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.

Input

There are at most $10000$ testcases.

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)$.

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 \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 ;
}

版权声明:本文为博主原创文章,未经博主允许不得转载。

时间: 2024-10-07 10:53:10

hdu5301(2015多校2)--Buildings(构造)的相关文章

2015多校.MZL&#39;s endless loop(欧拉回路的机智应用 || 构造)

MZL's endless loop Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 898    Accepted Submission(s): 178Special Judge Problem Description As we all kown, MZL hates the endless loop deeply, and he

HDU 5371 (2015多校联合训练赛第七场1003)Hotaru&#39;s problem(manacher+二分/枚举)

HDU 5371 题意: 定义一个序列为N序列:这个序列按分作三部分,第一部分与第三部分相同,第一部分与第二部分对称. 现在给你一个长为n(n<10^5)的序列,求出该序列中N序列的最大长度. 思路: 来自官方题解:修正了一些题解错别字(误 先用求回文串的Manacher算法,求出以第i个点为中心的回文串长度,记录到数组p中 要满足题目所要求的内容,需要使得两个相邻的回文串,共享中间的一部分,也就是说,左边的回文串长度的一半,要大于等于共享部分的长度,右边回文串也是一样. 因为我们已经记录下来以

HDU 5371 (2015多校联合训练赛第七场1003)Hotaru&amp;#39;s problem(manacher+二分/枚举)

pid=5371">HDU 5371 题意: 定义一个序列为N序列:这个序列按分作三部分,第一部分与第三部分同样,第一部分与第二部分对称. 如今给你一个长为n(n<10^5)的序列,求出该序列中N序列的最大长度. 思路: 来自官方题解:修正了一些题解错别字(误 先用求回文串的Manacher算法.求出以第i个点为中心的回文串长度.记录到数组p中 要满足题目所要求的内容.须要使得两个相邻的回文串,共享中间的一部分,也就是说.左边的回文串长度的一半,要大于等于共享部分的长度,右边回文串也

hdu 5288||2015多校联合第一场1001题

http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now OO want to know ∑i

hdu5289||2015多校联合第一场1002贪心+RMQ

http://acm.hdu.edu.cn/showproblem.php?pid=5289 Problem Description Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ability. Now, Tom is going to assign a special task to

hdu5348(2015多校5)--MZL&#39;s endless loop(搜索)

题目链接:点击打开链接 题目大意:给出n个点,m条无向边,现在要求将无向边变为有向边,要保证每个点的出度和入度的差不超过1 直接进行搜索,对每个点进行出度和入度的判断,如果出度大,就先进行反向的搜索(每搜索一条边u,v就认为这是一条v到u的有向边),反之,进行正向搜索(每搜到一条边u,v认为这是一条u到v的有向边),一直搜索到找不到边能继续为止. 注意: 1.已经使用过的边为了防止再次被遍历,可以修改head,head[u] = edge[i].next 2.注意自环,因为搜索是判断能不能继续向

hdu5379||2015多校联合第7场1011 树形统计

http://acm.hdu.edu.cn/showproblem.php? pid=5379 Problem Description Little sun is an artist. Today he is playing mahjong alone. He suddenly feels that the tree in the yard doesn't look good. So he wants to decorate the tree.(The tree has n vertexs, i

hdu5351(2015多校5)--MZL&#39;s Border(打表,,找规律)

题目链接:点击打开链接 题目大意:给出b1 = 'b' , b2 = 'a' , bi = b(i-1)b(i-2),将i-1和i-2链接起来,记录一个串的s[1-i] 和s[n-i+1-n]相同的话 Border,当i为最长是为LBorder,现在给让求在bn这个串上的前m个字符组成的子串的LBorder 通过计算可以发现,b字符串的前缀都是相同的,所以只要求出m的LBorder就行,和n是无关的,打表找出规律,找出对应不同的m,LBorder的值,因为存在大数,用java写 dp[i]第i层

hdu5353||2015多校联合第六场1001 贪心

http://acm.hdu.edu.cn/showproblem.php?pid=5353 Problem Description There are n soda sitting around a round table. soda are numbered from 1 to n and i-th soda is adjacent to (i+1)-th soda, 1-st soda is adjacent to n-th soda. Each soda has some candies