这个题就是给出一个大矩形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

Problem 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.
 
Source
 

最新文章

  1. Egret3D研究报告(二)从Unity3D导出场景到Egret3D
  2. 一个简单的app自动登录Python脚本案例
  3. Interesting things in Unity 4.5 you probably didn&#39;t know about
  4. Oracle表空间、段、区和块
  5. 无线路由器的“克隆MAC地址”是干什么作用的?
  6. 自定义实现简单的Android颜色选择器(附带源码)
  7. javascript中的undefined,null,&quot;&quot;,0和false的云集
  8. Log4net 写文件日志与数据库日志
  9. SQL Server优化之SQL语句优化
  10. AngularJs 基础(60分钟入门) (转)
  11. .Net项目框架
  12. vue.js移动端配置flexible.js
  13. python编码转换
  14. linux 清空history以及记录原理
  15. Maven入门指南⑥:将项目发布到私服
  16. vue使用animate.css库
  17. kbmmw 5.06.00 beta 发布
  18. Fragment中启动一个新的Activity
  19. jquery如何让checkbox如何取消勾选
  20. 006 --MySQL索引原理

热门文章

  1. zzulioj--1746--三角形面积(几何水题)
  2. 25.不改变原生数据的STL algorithm
  3. IE11 mobile 的 UA(User-Agent)
  4. 理解JavaScript Call()函数原理。
  5. NOIP 2012 疫情控制(二分+贪心+倍增)
  6. [洛谷P1939]【模板】矩阵加速(数列)
  7. 百度地图API的使用示例
  8. HTML学习----------DAY2第五节
  9. Looger级别
  10. 《AndroidStudio每日一贴》5. 怎样高速查看某个方法/注解的定义?