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. 机器学习:随机森林RF-OBB袋外错误率

    文章讲解比较详细,且有Python代码,可以作为有用的参考. 原文链接:http://blog.csdn.net/zhufenglonglove/article/details/51785220  参 ...

  2. 卸载pycharm再重新安装后,找不到第三方库

    遇到的问题: 看到pycharm出了新的版本,手痒把旧的版本卸载,然后安装了最新的版本,然后问题就来了. 之前通过PIP命令安装的第三方库,import的时候都报错,找不到模块.既然以前能正常使用,现 ...

  3. 腾讯模板引擎template

    template.js是一款JavaScript模板引擎,用来渲染页面的. 原理:提前将Html代码放进编写模板  script id="tpl" type="text/ ...

  4. eas之编辑表单元格

    --指定表列行单元不可编辑 // 锁定表格.行.列.单元 table.getStyleAttributes().getProtection().setLocked(true); row.getStyl ...

  5. Lua循环结构while循环、repeat 循环、for循环_学习笔记03

    Lua循环结构while循环.repeat 循环.for循环 while语法结构 while 循环条件 do 循环体  end --1.输出1到100 index = do print(index) ...

  6. 洛谷P1002 过河卒【dp】

    棋盘上AA点有一个过河卒,需要走到目标BB点.卒行走的规则:可以向下.或者向右.同时在棋盘上CC点有一个对方的马,该马所在的点和所有跳跃一步可达的点称为对方马的控制点.因此称之为"马拦过河卒 ...

  7. SQL中的条件判断语句(case when zhen if,ifnull)用法

    简介: case具有两种格式.简单case函数和case搜索函数.这两种方式,可以实现相同的功能.简单case函数的写法相对比较简洁,但是和case搜索函数相比,功能方面会有些限制,比如写判定式.还有 ...

  8. Firefly-rk3399 开发板环境搭建

    Firefly教程网站:http://wiki.t-firefly.com/zh_CN/Firefly-RK3399/started.html 系统烧录: http://wiki.t-firefly. ...

  9. python项目开发:ftp server开发

    程序要求: 1.用户加密认证 (对用户名密码进行MD5验证)2.允许同时多用户登陆 (使用socket server方法,为每个用户都创建一个信息文件)3.每个用户有自己的家目录,且只能访问自己的家目 ...

  10. 在MySQL的表中增加一列

    MySql中增加一列 如果想在一个已经建好的表中添加一列,可以用: alter table TABLE_NAME add column NEW_COLUMN_NAME varchar(45) not ...