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. SQL Server对数据进行删除

    SQL Server对数据进行删除,把页面的信息从数据库删除. auto"> <tr style="background:red"> <td> ...

  2. (转)基于Metronic的Bootstrap开发框架经验总结(5)--Bootstrap文件上传插件File Input的使用

    http://www.cnblogs.com/wuhuacong/p/4774396.html Bootstrap文件上传插件File Input是一个不错的文件上传控件,但是搜索使用到的案例不多,使 ...

  3. 数据库Day3之SQL Server 触发器

    最近在做一个人事管理系统写了几个简单的触发器 1.在删除员工信息表中员工信息时结果区提示被删除员工信息 create trigger teston 员工信息表after deleteasselect ...

  4. redis客户端连接到服务器的步骤

    和大多数客户端连接到服务器一样,redis-cli连接到服务器也主要分为两个阶段,请求连接阶段和数据传送阶段.具体来讲redis-cli做的事情有: 1.以socket方式建立连接: 2,选择相应的数 ...

  5. XML的解析方式

    //解析和输出XML public void showXml() { string filepath = Application.dataPath + @"/my.xml"; if ...

  6. 02-Linux命令基础-第02天(压缩包管理、服务器搭建与使用、vim)

    01-   复习 /boot 目录 引导项 八种文件类型: 文件:- 目录:d 软链接:l 字符设备文件:c 块设备文件:b 管道:p 套接字:s 未知 cp –a 保持源文件属性(如时间属性 如果不 ...

  7. 关于node对文件的读取

    设计: 通过终端git / cmd 获取用户输入路径,然后遍历路径下所有的文件,打印输出. 因为需要命令行交互,所以引入prompt库 (https://github.com/flatiron/pro ...

  8. [tyvj1957 Poetize5] Vani和Cl2捉迷藏 (最小路径可重点覆盖+二分图最大匹配)

    传送门 Description 这片树林里有N座房子,M条有向道路,组成了一张有向无环图. 树林里的树非常茂密,足以遮挡视线,但是沿着道路望去,却是视野开阔.如果从房子A沿着路走下去能够到达B,那么在 ...

  9. 【hihocoder 1297】数论四·扩展欧几里德

    [题目链接]:http://hihocoder.com/problemset/problem/1297 [题意] [题解] 问题可以转化为数学问题 即(s1+v1*t)%m == (s2+v2*t)% ...

  10. SQL Server 通过备份文件初始化复制 – 听风吹雨

    一.背景 MySQL在对有历史数据的数据库进行搭建复制(Master/Slave)的时候,可以通过在Master服务器备份历史数据,利用这个备份文件 在Slave进行还原:这样做的好处是可以更加快速的 ...