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. Java高级架构师(一)第21节:通过X-gen生成商品模块

    package com.sishuok.architecture1.goodsmgr.vo; import com.sishuok.architecture1.common.vo.BaseModel; ...

  2. 如何让vs2017 EF实体生成支持Mysql 和 Oracle?

    1.Mysql 安装   MySql Connector/Net        https://dev.mysql.com/downloads/connector/net/ 安装    mysql f ...

  3. wpf一些例子

    相关知识点:WPF - Adorner WPF Diagram Designer http://www.codeproject.com/Articles/484616/MVVM-Diagram-Des ...

  4. iOS: 格式化新浪微博/QQ说说等等的发布时间

    介绍:对于一些社交工具,我们可以发布一些说说或者心情什么的,如新浪微博,QQ,微信等,发布成功后,上面都会有一个发布的时间. 这个时间并不是具体的NSDate类型,而是经过格式化过的符合一般标准的模式 ...

  5. iOS:Xcode7下创建 .a静态库 和 .framework静态库

    Xcode7 中创建静态库:.a 和 .framework 一.简单介绍 1.什么是库? 库是程序代码的集合,是共享程序代码的一种方式 2.库的分类 根据源代码的公开情况,库可以分为2种类型 (1)开 ...

  6. C#之Raw Socket网络封包监视源码

    大家可以建立一个Windows Form应用程序,在下面的各个文件中添加对应的源码: //RawSocket.csnamespace ReceiveAll{ using System; using S ...

  7. http://blog.csdn.net/huang_xw/article/details/7090173

    http://blog.csdn.net/huang_xw/article/details/7090173

  8. java.lang.IllegalThreadStateException异常原因解析

    前几天写了个小程序,运行的时候发现在循环第二遍的时候出现了java.lang.IllegalThreadStateException异常 通过上网查询发现同一个Thread不能重复调用start方法, ...

  9. Java solr 索引数据增删改查

    具体代码如下: import java.io.IOException; import java.util.*; import org.apache.solr.client.solrj.SolrClie ...

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

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