HDU 5301 Buildings 数学
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 数学的更多相关文章
- hdu 5301 Buildings (2015多校第二场第2题) 简单模拟
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5301 题意:给你一个n*m的矩形,可以分成n*m个1*1的小矩形,再给你一个坐标(x,y),表示黑格子 ...
- HDU - 5301 Buildings
Buildings Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Total S ...
- HDU 5301 Buildings(2015多校第二场)
Buildings Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Tota ...
- 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 ...
- HDU 5301 Buildings 建公寓(逻辑,水)
题意:有一个包含n*m个格子的矩阵,其中有一个格子已经被染黑,现在要拿一些矩形来填充矩阵,不能填充到黑格子,但是每一个填充进去的矩形都必须至少有一条边紧贴在矩阵的边缘(4条边)的.用于填充的矩形其中最 ...
- bzoj4302 Hdu 5301 Buildings
传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=4302 [题解] 出自2015多校-学军 题意大概是给出一个n*m的格子有一个格子(x,y)是 ...
- 数学 HDOJ 5301 Buildings
题目传送门 /* 题意:n*m列的矩阵,删除一个格子x,y.用矩形来填充矩阵.且矩形至少有一边是在矩阵的边缘上. 求满足条件的矩形填充方式中面积最大的矩形,要使得该最大矩形的面积最小. 分析:任何矩形 ...
- hdoj 5301 Buildings
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5301 #include <iostream> #include <stdio.h&g ...
- hdu 4296 Buildings(贪婪)
主题链接:http://acm.hdu.edu.cn/showproblem.php? pid=4296 Buildings Time Limit: 5000/2000 MS (Java/Others ...
随机推荐
- 一. Jmeter--使用代理录制脚本
Jmeter脚本是以.JMX格式为主 1. Jmeter也是支持录制的,支持第三方录制方式和代理录制方式. (1).第三方录制主要是通过badboy来录制,录制后另存为jmx格式即可. (2).Jme ...
- ThinkPHP的输出和模型使用
1.假设在v层需要输出一个变量怎么办呢?即如同在html当中输出php代码. 可以直接使用{$name}代替.花括号被称之为标识符.可以通过修改配置项('TMPL_L_DELIM'=>'< ...
- 9 - Python函数定义-位置参数-返回值
目录 1 函数介绍 1.1 为什么要使用函数 1.2 Python中的函数 2 函数的基本使用 3 函数的参数 3.1 参数的默认值 3.2 可变参数 3.2.1 可变位置传参 3.2.2 可变关键字 ...
- windows 10添加定时任务
1.在搜索栏搜索‘任务计划’ 2.选择任务计划程序,打开 3.创建基本任务 4.输入任务名称 5.选择任务触发周期 6.选择任务触发的具体时间点 7.选择任务需要做的事 8.选择启动程序后,选择具体的 ...
- 13.Python3标准库--互联网
(一)urllib.parse:分解url urllib.parse模块提供了一些函数,可以管理URL以及组成部分 1.解析 from urllib.parse import urlparse ''' ...
- SwitchSharp代理插件的安装和使用
参考链接: http://bbs.feng.com/read-htm-tid-8227283.html 安装参考链接: http://jingyan.baidu.com/article/380abd0 ...
- linux -j 4
把源码编译成可执行的二进制文件, 4为服务器内核数
- 转:PHP环境搭建 - Linux
本文PHP环境采用,nginx + PHP7 + mysql 5.6 一.安装mysql 5.6 参见:http://www.cnblogs.com/rslai/p/7853465.html 二.Ng ...
- python基础(5)---整型、字符串、列表、元组、字典内置方法和文件操作介绍
对于python而言,一切事物都是对象,对象是基于类创建的,对象继承了类的属性,方法等特性 1.int 首先,我们来查看下int包含了哪些函数 # python3.x dir(int) # ['__a ...
- MySQL之基础功能
一.视图 视图:是一个虚拟表,其内容由查询定义.同真实的表一样,视图包含一系列带有名称的列和行数据 视图有如下特点: 1. 视图的列可以来自不同的表,是表的抽象和逻辑意义上建立的新关系. 2. 视图是 ...