HDU5301
题意:给n*m的矩形区域,剔除其中1*1的方块,然后用不同矩形块填充整个矩形区域,求需要的矩形块最大面积的最小值。
思路:先判把矩形矫正,然后特殊处理边值为奇数,且在中心点的情况,最后处理障碍在其他位置,这个时候要分别枚举障碍周围四个方块对应最外面窗户,正好有三个方向,所以取其中的最小值即可。
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std ;
int n , m , x , y , ans;
int ss()
{
ans = (n+1)/2 ;
if( n == m && n%2==1 && ans == x && ans == y )
ans-- ;
int flag = max(ans,max(min(x-1,min(y,m-y+1)),min(n-x,min(y,m-y+1))) );
return flag;
}
int main() { while( scanf("%d %d %d %d", &n, &m, &x, &y) != EOF ) {
if( n > m ) {
swap(n,m) ;
swap(x,y) ;
}
if( n == 1 )
printf("1\n") ;
else
printf("%d\n",ss());
}
return 0 ;
}
HDU5301的更多相关文章
- [2015hdu多校联赛补题]hdu5301 Buildings
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5301 题目大意:给你一块由1x1方格组成的矩形区域,其中有且仅有一个坏块,现在你要在上面建矩形的房子, ...
- 2015 多校联赛 ——HDU5301(技巧)
Your current task is to make a ground plan for a residential building located in HZXJHS. So you must ...
- hdu5301(2015多校2)--Buildings(构造)
Buildings Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) Tota ...
随机推荐
- SSH三种框架及表示层、业务层和持久层的理解
Struts(表示层)+Spring(业务层)+Hibernate(持久层) SSH:Struts(表示层)+Spring(业务层)+Hibernate(持久层) Struts:Struts是一个表示 ...
- iOS - Blocks
iOS中Blocks的介绍 1. 什么是Blocks Blocks是C语言的扩充功能.就是:带有自动变量的匿名函数. 类似C语言的函数指针.但Blocks不是一个指针,而是一个不带名字的函数, ...
- 【Java】Java Socket编程(1)基本的术语和概念
计算机程序能够相互联网,相互通讯,这使一切都成为可能,这也是当今互联网存在的基础.那么程序是如何通过网络相互通信的呢?这就是我记录这系列的笔记的原因.Java语言从一开始就是为了互联网而设计的,它为实 ...
- bzoj3043
这道题完全没想出来,引自 http://blog.csdn.net/willinglive/article/details/38419573的题解 对于带有“将一段区间内的每个数全部加上某个值”这种操 ...
- 【转】java 容器类使用 Collection,Map,HashMap,hashTable,TreeMap,List,Vector,ArrayList的区别
原文网址:http://www.360doc.com/content/15/0427/22/1709014_466468021.shtml java 容器类使用 Collection,Map,Hash ...
- 图论(网络流):SPOJ OPTM - Optimal Marks
OPTM - Optimal Marks You are given an undirected graph G(V, E). Each vertex has a mark which is an i ...
- 【线段树】BAPC2014 E Excellent Engineers (Codeforces GYM 100526)
题目链接: http://codeforces.com/gym/100526 http://acm.hunnu.edu.cn/online/?action=problem&type=show& ...
- 根据标点符号分行,StringBuilder的使用;将字符串的每个字符颠倒输出,Reverse的使用
一:根据标点符号分行,上图,代码很简单 二:代码 using System; using System.Collections.Generic; using System.ComponentModel ...
- 高效算法——G - 贪心
G - 贪心 Time Limit:3000MS Memory Limit:0KB 64bit IO Format:%lld & %llu Submit Status Desc ...
- 自定义WCF的配置文件
原文地址:http://www.cnblogs.com/shanyou/archive/2008/12/02/1346298.html WCF的承载既可以通过编码实现,也能够通过配置实现.而且使用配置 ...