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<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,x,y,ans;
int main(){
//freopen("in.txt","r",stdin);
while(~scanf("%d%d%d%d", &n, &m, &x, &y)){
if(n>m) swap(n,m),swap(x,y);//统一处理
ans=(n+)/;//短边的一半
int t1=max(x-,n-x),t2=min(y,m-y+);
if(ans<t2&&x-!=n-x) ans=min(t1,t2);
//如果x-1!=n-x,则t1>=ans,且此时若ans<t2,则说明纵向放置欠缺部分无法以横向放置替代
//因此,换成t1,则可以补足纵向放置欠缺,换成t2,则可以以横向放置替代纵向,取较小者
if(n==m&&x==y&&(x*-==n)) ans=(n-)/;
//如果在正中间,需特殊判定。
printf("%d\n",ans);
}
return ;
}

2015 多校赛 第二场 1002 (hdu 5301)的更多相关文章

  1. 2015 多校赛 第一场 1002 (hdu 5289)

    Description Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n ...

  2. 2015 多校赛 第二场 1006 (hdu 5305)

    Problem Description There are n people and m pairs of friends. For every pair of friends, they can c ...

  3. 2015 多校赛 第二场 1004 hdu(5303)

    Problem Description There are n apple trees planted along a cyclic road, which is L metres long. You ...

  4. 2015 多校赛 第一场 1007 (hdu 5294)

    总算今天静下心来学算法.. Description Innocent Wu follows Dumb Zhang into a ancient tomb. Innocent Wu’s at the e ...

  5. 2015 多校赛 第一场 1001 (hdu 5288)

    Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l&l ...

  6. 2019HDU多校赛第二场 H HDU 6598 Harmonious Army(最小割模型)

    参考博客https://blog.csdn.net/u013534123/article/details/97142191 #include<bits/stdc++.h> using na ...

  7. 可持久化线段树的学习(区间第k大和查询历史版本的数据)(杭电多校赛第二场1011)

    以前我们学习了线段树可以知道,线段树的每一个节点都储存的是一段区间,所以线段树可以做简单的区间查询,更改等简单的操作. 而后面再做有些题目,就可能会碰到一种回退的操作.这里的回退是指回到未做各种操作之 ...

  8. SCNU省选校赛第二场B题题解

    今晚的校赛又告一段落啦,终于"开斋"了! AC了两题,还算是满意的,英语还是硬伤. 来看题目吧! B. Array time limit per test 2 seconds me ...

  9. HDU 5305 Friends (搜索+剪枝) 2015多校联合第二场

    開始对点搜索,直接写乱了.想了想对边搜索,尽管复杂度高.剪枝一下水过去了. 代码: #include<cstdio> #include<iostream> #include&l ...

随机推荐

  1. Windows Phone 应用程序的生命周期(二)

    一.App.xaml.cs /// <summary> /// Application 对象的构造函数. /// </summary> public App() { // 未捕 ...

  2. js 获取属性名称,再根据这个属性名获取值

    if (result.success) { var obj = JSON.parse(result.data); var sltObj = document.getElementById(" ...

  3. RF学习使用记录【4】

    四 Extending Robot Framework 4.1 Creating test libraries RF的测试能力由测试库支持决定,已经有许多的测试库,有一些随着RF框架安装,但是更多的需 ...

  4. php第七节课

    多态,重载,克隆 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://ww ...

  5. 【Leetcode】【简单】【169求众数】【JavaScript】

    题目 169. 求众数 给定一个大小为 n 的数组,找到其中的众数.众数是指在数组中出现次数大于 ⌊ n/2 ⌋ 的元素. 你可以假设数组是非空的,并且给定的数组总是存在众数. 示例 1: 输入: [ ...

  6. Nginx服务(端口80)

    Nginx安装: 一.编译安装 1.安装相应软件 yum install pcre pcre-devel openssl openssl-devel -y 2.检查: rpm -aq pcre pcr ...

  7. eclipse IED 创建springboot项目教程

    学习使我沉淀变成淀粉.-- 沃兹基硕德[美] 首先给你的 eclipse 安装插件 Help> Eclipse Marketplace uploading-image-736738.png 所搜 ...

  8. vue.js 中 data, prop, computed, method,watch 介绍

    vue.js 中 data, prop, computed, method,watch 介绍 data, prop, computed, method 的区别 类型 加载顺序 加载时间 写法 作用 备 ...

  9. Problem 52

    Problem 52 It can be seen that the number, 125874, and its double, 251748, contain exactly the same ...

  10. xe7android调用webservice

    1.如果用的roservice,那么用builder打开rodl然后直接生成wsdl保存: 2.由系统IDE的Component中调用import WSDL后save as. 3.调用代码: HTTP ...