Buildings

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

Total Submission(s): 185    Accepted Submission(s): 25

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
 

题意:

n*m列的矩阵。删除一个格子x,y。用矩形来填充矩阵。

且矩形至少有一边是在矩阵的边缘上。求满足条件的矩形填充方式中面积最大的矩形,要使得该最大矩形的面积最小。

分析:

不论什么矩形都能够分为宽度为1的小矩形,所以仅仅考虑矩形的能够的最小长度就可以。

讨论:

不删除格子时:最小长度为min((n+1)/2,(m+1)/2) = len

n = m:

n为奇数。且当x,y在正中心的时候,len- 1就可以

其它条件len不变 ==== 显然成立

n != m:

假设n > m swap(n,m), swap(x,y)

因为对称性。把矩阵分为四块,把x,y变换到矩阵的右上角。

能够知道 删除点后len仅仅能变大不能变小。

且即使增大不会大于 (m+1)/2

0 0 0 0 0 0 0 0 0 0

0 x 0 0 0 0 0  0 0 0

1 3 0....

0 2 0 ....

如图:x下方的3必须被矩形覆盖,那么长度 为   min(1 到3的长度。2到3的长度)

然后取min((m+1)/2, max(len,min(1--->3,2---->3)))就可以

#include<cstdio>
#include<cstring>
#include<algorithm> #include<iostream>
using namespace std;
#define ll long long int main(){
ll n,m,x,y;
while(cin>>n>>m>>x>>y){
if(n > m ){
swap(n,m);
swap(x,y);
}
if(x > n - x + 1)
x = n - x + 1;
if(y > m - y + 1)
y = m - y + 1;
ll hm = ( m + 1) /2, hn = (n+1)/2;
ll ans = min(hm,hn);
if(m == n){
if(m % 2 == 1){
if( x == hn && y == hm)
ans--;
}
}
else {
ll f = min(y,n-x);
ans = max(ans,f);
ans = min(ans,hm);
}
cout<<ans<<endl;
}
return 0;
}

2015多校联合训练赛hdu 5301 Buildings 2015 Multi-University Training Contest 2 简单题的更多相关文章

  1. 2015多校联合训练赛 hdu 5308 I Wanna Become A 24-Point Master 2015 Multi-University Training Contest 2 构造题

    I Wanna Become A 24-Point Master Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 ...

  2. hdu 5381 The sum of gcd 2015多校联合训练赛#8莫队算法

    The sum of gcd Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) T ...

  3. hdu 5358 First One 2015多校联合训练赛#6 枚举

    First One Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Tota ...

  4. hdu 5361 2015多校联合训练赛#6 最短路

    In Touch Time Limit: 8000/4000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others) Total ...

  5. HDU 5358(2015多校联合训练赛第六场1006) First One (区间合并+常数优化)

    pid=5358">HDU 5358 题意: 求∑​i=1​n​​∑​j=i​n​​(⌊log​2​​S(i,j)⌋+1)∗(i+j). 思路: S(i,j) < 10^10 & ...

  6. HDU 5371 (2015多校联合训练赛第七场1003)Hotaru&#39;s problem(manacher+二分/枚举)

    pid=5371">HDU 5371 题意: 定义一个序列为N序列:这个序列按分作三部分,第一部分与第三部分同样,第一部分与第二部分对称. 如今给你一个长为n(n<10^5)的序 ...

  7. 2015多校联合训练赛 Training Contest 4 1008

    构造题: 比赛的时候只想到:前面一样的数,后面 是类似1,2,3,4,5,6....t这 既是:t+1,t+1...,1,2,3,...t t+1的数目 可能 很多, 题解时YY出一个N 然后对N   ...

  8. HDU OJ 5317 RGCDQ( 2015多校联合训练第3场) 暴力打表+小技巧

    题目连接:Click here 题意:在一个[L,R]内找到最大的gcd(f[i],f[j])其中L<=i<j<=R,f[x]表示i分解质因数后因子的种类数.eg:f[10]=2(1 ...

  9. HDU OJ 5326 Work( 2015多校联合训练第3场) 并查集

    题目连接:戳ME #include <iostream> #include <cstdio> #include <cstring> using namespace ...

随机推荐

  1. Fatal error: Incompatible file format: The encoded file has format major ID 1...解决方式

    申请好域名和空间后.将站点源代码上传到空间,解析好域名后.在地址栏输入域名出现以下错误: Fatal error: Incompatible file format: The encoded file ...

  2. COCOS学习笔记--Cocod2dx内存管理(三)-Coco2d-x内存执行原理

    通过上两篇博客.我们对Cocos引用计数和Ref类.PoolManager类以及AutoreleasePool类已有所了解,那么接下来就通过举栗子来进一步看看Coco2d-x内存执行原理是如何的. / ...

  3. h5-爆料view

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAdsAAABeCAIAAADkEim8AAAWAElEQVR4nO2d+1Nb55nHPbMz+1v+g/ ...

  4. 51nod-1462: 树据结构

    [传送门:51nod-1462] 简要题意: 给出一棵n个点的树,每个点有两个权值v,t 有Q个操作,有两种操作: 1.将x到根上的路径上的点的v值都加上d 2.将x到根上的路径上的点的t值都加上每个 ...

  5. BZOJ 3160: 万径人踪灭 FFT+快速幂+manacher

    BZOJ 3160: 万径人踪灭 题目传送门 [题目大意] 给定一个长度为n的01串,求有多少个回文子序列? 回文子序列是指从原串中找出任意个,使得构成一个回文串,并且位置也是沿某一对称轴对称. 假如 ...

  6. Batch Normalization的算法本质是在网络每一层的输入前增加一层BN层(也即归一化层),对数据进行归一化处理,然后再进入网络下一层,但是BN并不是简单的对数据进行求归一化,而是引入了两个参数λ和β去进行数据重构

    Batch Normalization Batch Normalization是深度学习领域在2015年非常热门的一个算法,许多网络应用该方法进行训练,并且取得了非常好的效果. 众所周知,深度学习是应 ...

  7. HDU 5863 cjj's string game (矩阵乘法优化递推)

    题目大意:用k种字符构建两个长度为n的字符串(每种字符有无限多个),要求对应位置字符相同的连续子串最长长度为m,问方法数. 其中k,n,m是输入,n(1<=n<=1000000000), ...

  8. vs的任务列表

    前几天才刚开始看到这个 很多时候,一些任务,怕忘记了,或者已经做好的东西,由于各种原因,暂时不用等等这种情况 这时候,就可以在vs上,随时加到任务列表中,方面下次直接来修改或实现等等 在vs的视图&g ...

  9. 洛谷P4014 分配问题(费用流)

    题目描述 有 nn 件工作要分配给 nn 个人做.第 ii 个人做第 jj 件工作产生的效益为 c_{ij}cij​ .试设计一个将 nn 件工作分配给 nn 个人做的分配方案,使产生的总效益最大. ...

  10. [ OS ][ Linux ] [ SA ] root 帳號名稱修改

    1. 背景: 由於 Linux 中預設最高權限的使用者一律為 root, 存在安全性的疑慮. 所以比較安全的作法要將 root 帳號改名為其他名稱,讓要入侵的人需要同時破解出帳號和密碼才可以進入主機, ...