hdoj5301
题意:
有一个n*m的大矩阵,
其中有一个1*1的不要的位置(x,y),
然后用若干个小矩阵去覆盖大矩阵,
不要的不能被覆盖。
问小矩阵中面积最大的面积最小是多少。
思路:
巨巨先画一个矩形,看看那个不要的在边上的时候;
再画个矩形,然后用四个矩阵把那个不要的包起来;
然后画个正方形(奇数),然后把不要的放在最中间。
很简单吧~
#include<bits/stdc++.h>
//#include<iostream>
//#include<math.h>
//#include<string.h>
//#include<algorithm>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int eps=1e-9;
const int pi=acos(-1.0);
const int mod=1e6+7;
const LL INF=0x3f3f3f3f;
int main()
{
int n,m,x,y,nn,mm,ans;
while(~scanf("%d%d%d%d",&n,&m,&x,&y))
{
nn=(n+1)/2;
mm=(m+1)/2;
if(n<=m)
{
if(x==1||x==n)
ans=min(n-1, min(y, m-y+1));
else if(y==1||y==m)
ans=min(m-1, min(x,n-x+1));
else
{
if(nn>=y||nn>m-y)
ans=nn;
else
ans=min(max(x-1,n-x),min(y,m-y+1));
}
ans=max(ans,nn);
}
else{
if(x==1||x==n)
ans=min(n-1,min(y,m-y+1));
else if(y==1||y==m)
ans=min(m-1,min(x,n-x+1));
else
{
if(mm>=x||mm>n-x)
ans=mm;
else
ans=min(max(y-1,m-y),min(x,n-x+1));
}
ans=max(ans,mm);
}
if(n==m&&x==y&&x==nn)
ans--;
printf("%d\n",ans);
}
return 0;
}
hdoj5301的更多相关文章
随机推荐
- overflow(超出部分省略号)
溢出:overflow:visible/hidden/scroll/auto/inherit: visible:默认值.不剪切.hidden:超出部分剪切.没有滚动条.scroll:超出部分有滚动条. ...
- POJ 2184 Cow Exhibition (01背包变形)(或者搜索)
Cow Exhibition Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10342 Accepted: 4048 D ...
- Appium启动报Permission Denial的问题
前言 在Android真机上跑自动化脚本时,发现在启动App时报java.lang.SecurityException: Permission Denial: starting Intent : 原先 ...
- (转载)常用的Mysql数据库操作语句大全
打开CMD,进入数据库命令:mysql -hlocalhost -uroot -p 退出数据库:exit 用户管理: 1.新建用户: >CREATE USER name IDENTIFIED B ...
- UnsatisfiedLinkError: No implementation found for , AndroidStudio使用*.so
今天工作的时候.发现了一个jni的问题,java.lang.UnsatisfiedLinkError: No implementation found for...... 问题1:后来查了资料后发现. ...
- POJ 2586 Y2K Accounting Bug(枚举大水题)
Y2K Accounting Bug Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10674 Accepted: 53 ...
- 每天一个JavaScript实例-apply和call的使用方法
<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content ...
- 自定义UISearchDisplayController的“No Results“标签和”Cancel“按钮
本文转载至 http://www.cnblogs.com/pengyingh/articles/2350154.html - (void)searchDisplayControllerWillBegi ...
- 中断线程Interrupt()
以下是参考<<Java多线程模式>>的 1. sleep() & interrupt() 线程A正在使用sleep()暂停着: Thread.sleep(100000) ...
- chmod|chown|chgrp和用法和区别
1.chgrp(改变文件所属用户组) chgrp 用户组 文件名 ###就是这个格了.如果整个目录下的都改,则加-R参数用于递归. 如:chgrp -R user smb.conf 2.c ...