Buildings

题目连接:

http://acm.hdu.edu.cn/showproblem.php?pid=5301

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

题意

给你一个n*m的土地,然后让你分成若干块,你需要保证这些块至少有一条边靠近土地的边上。

然后这个土地上有一个坏点。

问你这些块的最小面积是多少。

题解:

考虑暴力,显然答案就是其中某一块砖离边界最近距离值的最大值。

然后由于有一个坏点,那么我们就只用分析一下这个坏点附近的四个点就好了。

然后再考虑考虑特殊情况就好了。

代码

#include<bits/stdc++.h>
using namespace std; int n,m,a,b;
int main()
{
while(scanf("%d%d%d%d",&n,&m,&a,&b)!=EOF)
{
int ans;
int dis=0;
if(a*2==n+1&&b*2==m+1&&n==m)
{
cout<<a-1<<endl;
continue;
}
int x1=a,y1=b-1,x2=a,y2=b+1;
int x3=a-1,y3=b,x4=a+1,y4=b;
if(x1<=n&&x1>=1&&y1<=m&&y1>=1) dis=max(dis,min(x1,min(n-x1+1,y1)));
if(x2<=n&&x2>=1&&y2<=m&&y2>=1) dis=max(dis,min(x2,min(n-x2+1,m-y2+1)));
if(x3<=n&&x3>=1&&y3<=m&&y3>=1) dis=max(dis,min(y3,min(m-y3+1,x3)));
if(x4<=n&&x4>=1&&y4<=m&&y4>=1) dis=max(dis,min(y4,min(m-y4+1,n-x4+1)));
ans=max(dis,min((n+1)/2,(m+1)/2));
if(n)
cout<<ans<<endl;
}
}

HDU 5301 Buildings 数学的更多相关文章

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

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

  2. HDU - 5301 Buildings

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

  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内核线程kernel thread详解--Linux进程的管理与调度(十)【转】

    转自:http://blog.csdn.net/gatieme/article/details/51589205 日期 内核版本 架构 作者 GitHub CSDN 2016-06-02 Linux- ...

  2. http状态码说明

    在学习网页设计的时候都应该知道状态码,但我们常见的状态码都是200,404,下面介绍其他的状态值 1开头的http状态码表示临时响应并需要请求者继续执行操作的状态代码. 100   (继续) 请求者应 ...

  3. 45.Jump Game II---贪心---2018大疆笔试题

    题目链接 题目大意:与55题类似,只是这里要求出跳数. 法一(借鉴):贪心.cur表示当前能到达的最远距离,pre表示上一次能到达的最远距离,每到一个位置更新一次最远距离cur,如果当前位置超过了上一 ...

  4. 总结开发ERP软件应遵循的一些基本原则

    总结一下做管理软件,有哪些项是经过检验的条款,必须遵守的. 界面篇 1  要保存用户的偏号(profile/favourite). ASP.NET 2.0引入此功能,当用户修改默认的控件的属性时,框架 ...

  5. centos修改oracle字符集

    1.首先以sysdba的身份登录上去 conn /as sysdba2.关闭数据库shutdown immediate;3.以mount打来数据库,startup mount4.设置session S ...

  6. rest api load test

    1. SoapUI + LoadUI 2. https://github.com/jeffbski/bench-rest 3. JMeter

  7. yii2 GirdView使用全教程

    开始GridView GridView主要是为了实现表格复用,尤其我们做后台的时候,你发现表单和表格占据了大部分页面,而表格的样式又是高度的统一,那么如果有这样一个挂件,传入数据集自动渲染表格该多好. ...

  8. Typo: In word 拼写检查

    Settings->Inspections > Spelling > Typo 评写检查,

  9. laravel windows安装(composer)

    1.安装composer参考windows 安装tp5 composer方式 2.先配置好本地虚拟域名,在cmd里面切换到网站根目录 ... 3.安装成功之后,在浏览器输入已配置的虚拟域名我的是,la ...

  10. poj1753 Flip Game(BFS+位压缩)

    题目链接 http://poj.org/problem?id=1753 题意 一个棋盘上有16个格子,按4×4排列,每个格子有两面,两面的颜色分别为黑色和白色,游戏的每一轮选择一个格子翻动,翻动该格子 ...