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. WordPress的SEO插件——WordPress SEO by yoast安装及使用

    插件:WordPress SEO by yoast 使用方法: 做好网站SEO一直是站长们的愿望,说简单也简单,但是说难也难,因为需要注意的地方太多,一个不小心被百度K了你都不知道怎么回事.这里和大家 ...

  2. Android Service使用简单介绍

    作为一个android初学者,经常对service的使用感到困惑.今天结合Google API 对Service这四大组件之一,进行简单使用说明. 希望对和我一样的初学者有帮助,如有不对的地方,也希望 ...

  3. AES,SHA1,DES,RSA,MD5区别

    AES:更快,兼容设备,安全级别高: SHA1:公钥后处理回传 DES:本地数据,安全级别低 RSA:非对称加密,有公钥和私钥 MD5:防篡改 相关: 公开密钥加密(英语:public-key cry ...

  4. inet_addr_onlink

    /* 根据指定设备的ip配置块,判断地址a,b是否在同一子网 */ /* --邻居项要求,在同一子网中的两个设备, 至少有一个接口有相同的子网配置, --也就是说对端的in_dev->ifa_l ...

  5. 安全测试===dos攻击和ddos攻击

    Dos攻击: dos攻击是Denial of Service的简称,即拒绝服务,造成DoS的攻击行为被称为DoS攻击,其目的是使计算机或网络无法提供正常的服务 DoS攻击是指故意的攻击网络协议实现的缺 ...

  6. 非交互式shell脚本案例-实现自主从oracle数据库获取相关数据,并在制定目录生成相应规则的文件脚本

    get_task_id 脚本内容 #!/usr/bin/expect#配置登陆数据库的端口set port 22#配置登陆数据库的ip地址set oracleip 10.0.4.41#配置数据库实例名 ...

  7. 你需要知道的Nginx配置二三事

    做服务端开发的,工作中难免会遇到处理Nginx配置相关问题.在配置Nginx时,我一直本着“照葫芦画瓢”的原则,复制已有的配置代码,自己修修改改然后完成配置需求,当有人问起Nginx相关问题时,其实仍 ...

  8. jmeter------reponse报错”Unknown column 'XXXXX' in 'where clause'“

    一.问题描述 jmeter添加了与数据库mysql的连接,编写完JDBC Request之后,运行提示报错”Unknown column 'be7f5b6e750bb6becf855386338644 ...

  9. Jmeter----请求的reponse结果中的某个参数作为JDBC Request的查询条件

    一.前言 数据库连接成功,若不会的查看:https://www.cnblogs.com/syw20170419/p/9832402.html 二.需求 将登录账号12608523691,接口的repo ...

  10. 微软企业库5.0 学习之路——第九步、使用PolicyInjection模块进行AOP—PART4——建立自定义Call Handler实现用户操作日志记录

    在前面的Part3中, 我介绍Policy Injection模块中内置的Call Handler的使用方法,今天则继续介绍Call Handler——Custom Call Handler,通过建立 ...