2015 多校联赛 ——HDU5301(技巧)
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).
3 3 1 1
2
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.
题意:
n*m矩阵,黑格子的位置是(x,y),将剩下位置划分为多个矩阵,每个矩阵必须接触边缘,求出划分矩阵的最大最小面积。
题解:先换成 N<M的矩形,ans = (min(n,m) + 1)/2;
1. min(left,right)> ans
Answer = min(max(up,down),min(left,right));
2.为奇数正方形,且x,y 在正中央时,answer = ans-1;
3.否则,ans
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <map>
#include <algorithm>
#define MAX 0x3f3f3f3f
using namespace std;
typedef long long ll;
ll n,m,x,y; int main()
{
while(~scanf("%I64d%I64d%I64d%I64d",&n,&m,&x,&y))
{
if(n < m)
{
swap(n,m);
swap(x,y);
} if(n == m && n%2 && x == (n+1)/2 && y == (m+1)/2)
{
printf("%d\n", m/2);
continue;
} int maxn = (m +1)/2; if(x == 1 || x == n || y == maxn || y == maxn + 1 )
printf("%d\n",maxn);
else
{
int ans = max(y-1,m-y);
int temp = min(x,n-x+1);
if(temp < maxn)
printf("%d\n",maxn);
else
printf("%d\n",min(ans,temp));
} }
return 0;
}
2015 多校联赛 ——HDU5301(技巧)的更多相关文章
- 2015 多校联赛 ——HDU5334(构造)
Virtual Participation Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Ot ...
- 2015 多校联赛 ——HDU5302(构造)
Connect the Graph Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others ...
- 2015 多校联赛 ——HDU5294(最短路,最小切割)
Tricks Device Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) To ...
- 2015 多校联赛 ——HDU5325(DFS)
Crazy Bobo Time Limit: 6000/3000 MS (Java/Others) Memory Limit: 131072/65536 K (Java/Others) Tota ...
- 2015 多校联赛 ——HDU5316(线段树)
Fantasy magicians usually gain their ability through one of three usual methods: possessing it as an ...
- 2015 多校联赛 ——HDU5323(搜索)
Solve this interesting problem Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K ...
- 2015 多校联赛 ——HDU5319(模拟)
Painter Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Su ...
- 2015 多校联赛 ——HDU5303(贪心)
Delicious Apples Time Limit: 5000/3000 MS (Java/Others) Memory Limit: 524288/524288 K (Java/Other ...
- 2015 多校联赛 ——HDU5305(搜索)
Friends Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Su ...
随机推荐
- 1013团队alpha冲刺日志集合帖
alpha冲刺day1 alpha冲刺day2 alpha冲刺day3 alpha冲刺day4 alpha冲刺day5 alpha冲刺day6 alpha冲刺day7 alpha冲刺day8 alph ...
- iOS 简易无限滚动的图片轮播器-SDCycleScrollView
@interface ViewController () <</span>SDCycleScrollViewDelegate> @end @implementation Vie ...
- 要学好JAVA要注意些什么?
从自学开始到参加系统的学习JAVA已经差不多有1个月了的时间了,在这段时间以前我也和很多人一样在网上盲目的搜罗一些视频来自己啃,随着时间的积累,对JAVA的认识也有了一定的提升,之前可能因为在IT咨询 ...
- Django之ORM字段和参数
字段 常用字段 AutoField ...
- nyoj 还是回文
还是回文 时间限制:2000 ms | 内存限制:65535 KB 难度:3 描述 判断回文串很简单,把字符串变成回文串也不难.现在我们增加点难度,给出一串字符(全部是小写字母),添加或删除一个字符, ...
- nyoj 仿射密码
仿射密码 时间限制:1000 ms | 内存限制:65535 KB 难度:1 描述 仿射密码是替换密码的另一个特例,可以看做是移位密码和乘数密码的结合.其加密变换如下: E(m)=(k1*m+k2) ...
- 70后.net老猿,尚能饭否?
程序猿的大限 距离上一次主动找工作,快到5年了,到现在的东家,是差不多3年前猎头挖过来的,而当时东家刚刚被欧洲一家有百年历史的跨国企业集团收购,所以我也就有幸成了一名“外企员工”,但是集团保留原东家人 ...
- 一个诚实的孩纸选Python的原因
我之所以会选择python语言程序设计这门课,是因为我一开始预选选的选修课都没选上,然后在补选的时候,在别人选剩的课里面选择了python. 上了两节课之后,我发现python还挺有意思的,挺喜欢py ...
- appiun滑动的简单封装
import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.test ...
- redis入门(05)redis的key命令
一.什么是redis键命令 Redis 键(key):Redis 键命令用于管理 redis 的键. Redis 键命令的基本语法: redis 127.0.0.1:6379> COMMAND ...