这个题就是给出一个大矩形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,且都是奇数,切被占格子在正中间的情况就可以。

  1. #include<map>
  2. #include<string>
  3. #include<cstring>
  4. #include<cstdio>
  5. #include<cstdlib>
  6. #include<cmath>
  7. #include<queue>
  8. #include<vector>
  9. #include<iostream>
  10. #include<algorithm>
  11. #include<bitset>
  12. #include<climits>
  13. #include<list>
  14. #include<iomanip>
  15. #include<stack>
  16. #include<set>
  17. using namespace std;
  18. int a[10];
  19. int main()
  20. {
  21. int n,m,x,y;
  22. while(cin>>n>>m>>x>>y)
  23. {
  24. if(n==m&&(n&1)&&x==n+1>>1&&y==x)
  25. {
  26. cout<<(n+1>>1)-1<<endl;
  27. continue;
  28. }
  29. if(n>m)
  30. {
  31. swap(n,m);
  32. swap(x,y);
  33. }
  34. a[0]=x-1;
  35. a[1]=n-x;
  36. a[2]=y;
  37. a[3]=m-y+1;
  38. a[4]=n+1>>1;
  39. int ans=max(a[4],min(max(a[0],a[1]),min(a[2],a[3])));
  40. cout<<ans<<endl;
  41. }
  42. }

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
  1. 2 3 2 2
  2. 3 3 1 1
 
Sample Output
  1. 1
  2. 2
  3. Hint
  4. Case 1 :

  5. You can split the floor into five 1×1 apartments. The answer is 1.
  6. Case 2:

  7. You can split the floor into three 2×1 apartments and two 1×1 apartments. The answer is 2.

  8. 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.
  9.  
 
Source
 

图解hdu5301Buildings的更多相关文章

  1. 图解CSS3制作圆环形进度条的实例教程

    圆环形进度条制作的基本思想还是画出基本的弧线图形,然后CSS3中我们可以控制其旋转来串联基本图形,制造出部分消失的效果,下面就来带大家学习图解CSS3制作圆环形进度条的实例教程 首先,当有人说你能不能 ...

  2. 《图解HTTP》读书笔记

    目前国内讲解HTTP协议的书是在太少了,记忆中有两本被誉为经典的书<HTTP权威指南>与<TCP/IP详解,卷1>,但内容晦涩难懂,学习难度较大.其实,HTTP协议并不复杂,理 ...

  3. [PostgreSQL] 图解安装 PostgreSQL

    图解安装 PostgreSQL [博主]反骨仔 [原文地址]http://www.cnblogs.com/liqingwen/p/5894462.html 序 园友的一篇<Asp.Net Cor ...

  4. 图解ios程序生命周期

    图解ios程序生命周期 应用程序启动后状态有Active.Inactive.Background.Suspended.Not running这5种状态,几种状态的转换见下图: 在AppDelegate ...

  5. 【用xocde5打包 在IOS7以下也能显示无默认gloss 效果 图解】

    图解,只需要这几个地方修改以下就好了,看不懂的话,请留言 完毕:记着clean 以下项目文件

  6. Python开发工具PyCharm个性化设置(图解)

    Python开发工具PyCharm个性化设置,包括设置默认PyCharm解析器.设置缩进符为制表符.设置IDE皮肤主题等,大家参考使用吧. JetBrains PyCharm Pro 4.5.3 中文 ...

  7. (转)Eclipse和MyEclipse安装和使用git(egit)图解笔记

    Eclipse.MyEclipse使用git插件(egit)图解 (转)原文来自:http://www.xuebuyuan.com/446322.html 在开发Java.JavaEE等相关程序时,我 ...

  8. C#温故知新:《C#图解教程》读书笔记系列

    一.此书到底何方神圣? 本书是广受赞誉C#图解教程的最新版本.作者在本书中创造了一种全新的可视化叙述方式,以图文并茂的形式.朴实简洁的文字,并辅之以大量表格和代码示例,全面.直观地阐述了C#语言的各种 ...

  9. 字符串模式匹配之KMP算法图解与 next 数组原理和实现方案

    之前说到,朴素的匹配,每趟比较,都要回溯主串的指针,费事.则 KMP 就是对朴素匹配的一种改进.正好复习一下. KMP 算法其改进思想在于: 每当一趟匹配过程中出现字符比较不相等时,不需要回溯主串的 ...

随机推荐

  1. hdoj--3552--I can do it!(贪心模拟)

    I can do it! Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others) Tot ...

  2. C#篇(三)——函数传参之引用类型和值类型

    首先应该认清楚在C#中只有两种类型: 1.引用类型(任何称为"类"的类型) 2.值类型(结构或枚举) 先来认识一下引用类型和值类型的区别: 函数传参之引用类型: 1.先来一个简单的 ...

  3. 使用ShareSDK分享-图片的链接

    微信中使用ShareSDK分享,需要申请微信开放平台账号,并且以微信中的声明的应用签名打包程序. private void showShare(String url, String title, St ...

  4. 关于node的聊天室错误

    Deprecationwarning:process,EventEmitter is deprecated use require ('events')instead 关于node的聊天室错误 > ...

  5. mutt发邮件

    在 /etc/Muttrc 文件添加以下内容:   set from="laughingliang@chaincar.com" set use_from=yes set envel ...

  6. last-child到底怎么用

    今天工作时候遇到的坑, 看来还是css基础不够扎实,特此记录一下, <div> <p>1</p> <p>2</p> <p>3&l ...

  7. md5sum---文件校验和

    md5sum命令采用MD5报文摘要算法(128位)计算和检查文件的校验和.一般来说,安装了Linux后,就会有md5sum这个工具,直接在命令行终端直接运行. MD5算法常常被用来验证网络文件传输的完 ...

  8. 紫书 例题 10-7 UVa 10820 (欧拉函数)

    这道题要找二元组(x, y) 满足1 <= x, y <= n 且x与y互素 那么我就可以假设x < y, 设这时答案为f(n) 那么答案就为2 * f(n) +1(x与y反过来就乘 ...

  9. 紫书 例题 10-28 UVa 1393(简化问题)

    这道题是对称的 所以只算"\", 最后答案再乘以2 然后每一条直线看作一个包围盒 枚举包围盒的长宽 有两种情况会重复 (1)包围盒里面有包围盒. 这个时候就是在一条直线上 那么我们 ...

  10. Unity shader 代码高亮+提示

    Shader Unity Support This is Unity CG Shaders Support. It has code completion support and uses C/C++ ...