图解hdu5301Buildings
这个题就是给出一个大矩形n*m。当中有个1*1的小格子不能被占用,然后要你用非常多小矩形去填满。问小矩形的最小最大面积是多少。
显然小矩形必定是1*x的最好,毕竟i*x,若i>1则还是能够拆成非常多1*x。
显然若没有那个被占用的格子。那么答案就是min(n,m)+1>>1。
当考虑这个格子的时候,我们把矩形调整下,保证n<m,然后就非常显然,除了被格子占用的那一列j,其它的列k,不管k<j还是k>j必定至少有一个还是用(min(n,m)+1>>1)*1的矩形去竖着填最好,那么考虑仅仅有一个被这样的方案填了,那么还有一个肯定要用这样的方案或者考虑横着填。
这两种情况画出来就是这样:
上面的图,同一种颜色代表由相同的1*x的小矩形组成的部分,第一张图的左边是横着插。第二张图右边都是竖着插。
于是就能够非常显然的推出式子。另外再单独考虑n=m,且都是奇数,切被占格子在正中间的情况就可以。
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<vector>
#include<iostream>
#include<algorithm>
#include<bitset>
#include<climits>
#include<list>
#include<iomanip>
#include<stack>
#include<set>
using namespace std;
int a[10];
int main()
{
int n,m,x,y;
while(cin>>n>>m>>x>>y)
{
if(n==m&&(n&1)&&x==n+1>>1&&y==x)
{
cout<<(n+1>>1)-1<<endl;
continue;
}
if(n>m)
{
swap(n,m);
swap(x,y);
}
a[0]=x-1;
a[1]=n-x;
a[2]=y;
a[3]=m-y+1;
a[4]=n+1>>1;
int ans=max(a[4],min(max(a[0],a[1]),min(a[2],a[3])));
cout<<ans<<endl;
}
}
Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others)
Total Submission(s): 1237 Accepted Submission(s): 335
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.
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).
2 3 2 2
3 3 1 1
1
2HintCase 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.
图解hdu5301Buildings的更多相关文章
- 图解CSS3制作圆环形进度条的实例教程
圆环形进度条制作的基本思想还是画出基本的弧线图形,然后CSS3中我们可以控制其旋转来串联基本图形,制造出部分消失的效果,下面就来带大家学习图解CSS3制作圆环形进度条的实例教程 首先,当有人说你能不能 ...
- 《图解HTTP》读书笔记
目前国内讲解HTTP协议的书是在太少了,记忆中有两本被誉为经典的书<HTTP权威指南>与<TCP/IP详解,卷1>,但内容晦涩难懂,学习难度较大.其实,HTTP协议并不复杂,理 ...
- [PostgreSQL] 图解安装 PostgreSQL
图解安装 PostgreSQL [博主]反骨仔 [原文地址]http://www.cnblogs.com/liqingwen/p/5894462.html 序 园友的一篇<Asp.Net Cor ...
- 图解ios程序生命周期
图解ios程序生命周期 应用程序启动后状态有Active.Inactive.Background.Suspended.Not running这5种状态,几种状态的转换见下图: 在AppDelegate ...
- 【用xocde5打包 在IOS7以下也能显示无默认gloss 效果 图解】
图解,只需要这几个地方修改以下就好了,看不懂的话,请留言 完毕:记着clean 以下项目文件
- Python开发工具PyCharm个性化设置(图解)
Python开发工具PyCharm个性化设置,包括设置默认PyCharm解析器.设置缩进符为制表符.设置IDE皮肤主题等,大家参考使用吧. JetBrains PyCharm Pro 4.5.3 中文 ...
- (转)Eclipse和MyEclipse安装和使用git(egit)图解笔记
Eclipse.MyEclipse使用git插件(egit)图解 (转)原文来自:http://www.xuebuyuan.com/446322.html 在开发Java.JavaEE等相关程序时,我 ...
- C#温故知新:《C#图解教程》读书笔记系列
一.此书到底何方神圣? 本书是广受赞誉C#图解教程的最新版本.作者在本书中创造了一种全新的可视化叙述方式,以图文并茂的形式.朴实简洁的文字,并辅之以大量表格和代码示例,全面.直观地阐述了C#语言的各种 ...
- 字符串模式匹配之KMP算法图解与 next 数组原理和实现方案
之前说到,朴素的匹配,每趟比较,都要回溯主串的指针,费事.则 KMP 就是对朴素匹配的一种改进.正好复习一下. KMP 算法其改进思想在于: 每当一趟匹配过程中出现字符比较不相等时,不需要回溯主串的 ...
随机推荐
- [BZOJ4289] [PA2012] Tax 解题报告 (最短路+差分建图)
题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=4289 4289: PA2012 Tax Time Limit: 10 Sec Memo ...
- 如何设置eclipse代码自动提示功能
如何设置eclipse代码自动提示功能 我们在刚安装完使用eclipse进行开发时,会发现没有代码提示会非常的不方便,下面小编将告诉你如何进行代码自动提示的设置. 工具/原料 eclipse 电脑 ...
- SharePoint UserProfileService 接口列表 注解
Remove Leader 除去领袖 Add Leader 加领袖 Get leaders 获得管理员 Get Profile Scherna Get Profile Scherna Names ...
- 基于Struts2+MySQL的多表出差明细表单
下载地址:http://download.csdn.net/detail/qq_33599520/9790629 项目结构: UserAction package com.mstf.action; i ...
- mac terminal终端怎么退出python命令行
>>>使用 quit(), exit(), 或者Command+d,或者Command+z退出命令行.
- ES6学习笔记(十五)Generator函数的异步应用
1.传统方法 ES6 诞生以前,异步编程的方法,大概有下面四种. 回调函数 事件监听 发布/订阅 Promise 对象 Generator 函数将 JavaScript 异步编程带入了一个全新的阶段. ...
- JS由Number与new Number的区别引发的思考
在回答园子问题的时候发现了不少新东西,写下来分享一下 == 下面的图就是此篇的概览,另外文章的解释不包括ES6新增的Symbol,话说这货有包装类型,但是不能new... 基于JS是面向对象的,所以我 ...
- java 基于 bootstrap_datagrid 分页
1.首先引入datagrid js ,css $("#datagrid").bootstrap_datagrid({ url : "<%=path%>/us ...
- 今日SGU 5.26
#include<bits/stdc++.h> #define de(x) cout<<#x<<"="<<x<<endl ...
- Java基础学习总结(11)——重载与重写
首先我们来讲讲:重载(Overloading) 一.方法的重载 方法名一样,但参数不一样,这就是重载(overload). 所谓的参数不一样,主要有两点:第一是参数的个数不一样,第二是参数的类型不一样 ...


