Buildings

Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)

Total Submission(s): 387 Accepted Submission(s): 81

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≤108,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.

#include <cstdio>
#include <algorithm>
using namespace std; int main() {
int n, m, x, y;
while (scanf("%d%d%d%d", &n, &m, &x, &y) != EOF) {
if (n == m && x == y && n % 2 == 1 && n / 2 + 1 == x) {
printf("%d\n", n / 2);
continue;
}
int tx = min(x, n - x + 1);
tx = max(tx, min((m + 1) / 2, n - tx)); int ty = min(y, m - y + 1);
ty = max(ty, min((n + 1) / 2, m - ty));
int t = min(tx, ty);
printf("%d\n", t);
}
return 0;
}

HDU - 5301 Buildings的更多相关文章

  1. HDU 5301 Buildings 数学

    Buildings 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5301 Description Your current task is to m ...

  2. hdu 5301 Buildings (2015多校第二场第2题) 简单模拟

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5301 题意:给你一个n*m的矩形,可以分成n*m个1*1的小矩形,再给你一个坐标(x,y),表示黑格子 ...

  3. HDU 5301 Buildings(2015多校第二场)

    Buildings Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Tota ...

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

  5. HDU 5301 Buildings 建公寓(逻辑,水)

    题意:有一个包含n*m个格子的矩阵,其中有一个格子已经被染黑,现在要拿一些矩形来填充矩阵,不能填充到黑格子,但是每一个填充进去的矩形都必须至少有一条边紧贴在矩阵的边缘(4条边)的.用于填充的矩形其中最 ...

  6. bzoj4302 Hdu 5301 Buildings

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4302 [题解] 出自2015多校-学军 题意大概是给出一个n*m的格子有一个格子(x,y)是 ...

  7. 数学 HDOJ 5301 Buildings

    题目传送门 /* 题意:n*m列的矩阵,删除一个格子x,y.用矩形来填充矩阵.且矩形至少有一边是在矩阵的边缘上. 求满足条件的矩形填充方式中面积最大的矩形,要使得该最大矩形的面积最小. 分析:任何矩形 ...

  8. hdoj 5301 Buildings

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5301 #include <iostream> #include <stdio.h&g ...

  9. hdu 4296 Buildings(贪婪)

    主题链接:http://acm.hdu.edu.cn/showproblem.php? pid=4296 Buildings Time Limit: 5000/2000 MS (Java/Others ...

随机推荐

  1. linux下查看端口占用情况以及服务启动的目录

    1.先介绍几个命令: 1. lsof -i:80 查看80端口的占用情况 命令返回结果: COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME ngin ...

  2. 正则表达式之 /^(\d)$/

    ^(\d)$就是0-9的任意一个数字, ^表示以...开头,\d表示0-9的数字,$表示以...结尾,

  3. [Java基础] Java多线程-工具篇-BlockingQueue

    转载自: http://www.cnblogs.com/jackyuj/archive/2010/11/24/1886553.html 前言: 在新增的Concurrent包中,BlockingQue ...

  4. linux下获取占用CPU资源最多的10个进程

    linux下获取占用CPU资源最多的10个进程,可以使用如下命令组合: ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head linux下获取占用 ...

  5. CSS3 animation动画

    CSS3 animation动画 1.@keyframes 定义关键帧动画2.animation-name 动画名称3.animation-duration 动画时间4.animation-timin ...

  6. HAWQ技术解析(十八) —— 问题排查

    (原文地址:http://hawq.incubator.apache.org/docs/userguide/2.1.0.0-incubating/troubleshooting/Troubleshoo ...

  7. 用table表格来调整控件的格式

    由于想自己写一个web,所以也在学习html语言的一些东西,让我回忆起了大学时代曾对网页设计产生过兴趣,无奈那时候还没有自己的电脑,还常去网吧买个软盘下载一些图片,然后用fontpage做一些网页.后 ...

  8. php中一些函数的用法

    addslashes() 定义和用法 addslashes() 函数返回在预定义字符之前添加反斜杠的字符串. 预定义字符是: 单引号(') 双引号(") 反斜杠(\) NULL 提示:该函数 ...

  9. LOGO闪光效果

    原地址:http://cl314413.blog.163.com/blog/static/1905079762014122105235138/ 这个效果在很多LOGO及广告宣传中都会用到.商业开发的做 ...

  10. NSDate 问题

    类型 比特数 有效数字 数值范围 float 32 6-7 -3.4*10(-38)-3.4*10(38) double 64 15-16 -1.7*10(-308)-1.7*10(308) long ...