博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
2015 Multi-University Training Contest 2 Buildings
阅读量:5300 次
发布时间:2019-06-14

本文共 2482 字,大约阅读时间需要 8 分钟。

Buildings

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)

Total Submission(s): 804    Accepted Submission(s): 222

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(1n,m108,n×m>1,1xn,1ym).
 

 

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*x的形状,所以只要最长边最短即可。当x < ret 时 影响最大的应该是下部分 黑块下的那小块怎么让他拥有窗户

可以选择拥有左边 可以选择下边 可以选择右边 取最小就是了,其余的部分 最大莫过于ret了。。。

x > ret时 是上部分 同理

 

 

1 #include 
2 using namespace std; 3 int main(){ 4 int n,m,x,y; 5 while(~scanf("%d%d%d%d",&n,&m,&x,&y)){ 6 int ret = (min(n,m)+1)>>1; 7 if(n > m) {swap(n,m);swap(x,y);} 8 if((n&1) && n == m && y == ret && x == ret) --ret; 9 if(x < ret) ret = max(ret,min(n-x,min(y,m-y+1)));10 else if(x > ret) ret = max(ret,min(x-1,min(y,m-y+1)));11 printf("%d\n",ret);12 }13 return 0;14 }
View Code

 

转载于:https://www.cnblogs.com/crackpotisback/p/4672589.html

你可能感兴趣的文章
E4 - 使用Model Fragments扩展视图
查看>>
pip install torch on windows, and the 'from torch._C import * ImportError: DLL load failed:' s...
查看>>
zencart iis 伪静态设置 测试可用
查看>>
环套树
查看>>
中英文混合字符串长度
查看>>
[转]Repeat Page Header on each Page for reports SSRS
查看>>
Spring中事务传播行为
查看>>
java基础(一):我对java的三个环境变量的简单理解和配置
查看>>
arcgis api 4.x for js 结合 Echarts4 实现散点图效果(附源码下载)
查看>>
YTU 2734: 国家排序
查看>>
YTU 2625: B 构造函数和析构函数
查看>>
Notepad++ 16进制编辑功能
查看>>
Caffe: Cannot create Cublas handle. Cublas won't be available
查看>>
Linux 下 LXD 容器搭建 Hadoop 集群
查看>>
mysql describe
查看>>
apache自带压力测试工具ab的使用及解析
查看>>
C语言作业3
查看>>
C#使用Xamarin开发可移植移动应用(2.Xamarin.Forms布局,本篇很长,注意)附源码
查看>>
koogra--Excel文件读取利器
查看>>
ASP.NET 使用ajaxupload.js插件出现上传较大文件失败的解决方法
查看>>