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的更多相关文章
随机推荐
- call lua function from c and called back to c
Just a simple example: --The c file: #include <stdio.h> #include "lua.h" #include & ...
- 使用azure send grid发送email
1. create a send grid account 2. remember the username/password of the send grid account watermark/2 ...
- C++模板实现的AVL树
1 AVL树的定义 AVL树是一种自平衡二叉排序树.它的特点是不论什么一个节点的左子树高度和右子树的高度差在-1,0,1三者之间. AVL树的不论什么一个子树都是AVL树. 2 AVL树的实现 AVL ...
- FastDFS的配置、部署与API使用解读(1)Get Started with FastDFS(转)
转载请注明来自:诗商·柳惊鸿CSDN博客,原文链接:FastDFS的配置.部署与API使用解读(1)入门使用教程 1.背景 FastDFS是一款开源的.分布式文件系统(Distributed File ...
- Android安装应用后点击"打开"(Open)带来的问题及解决方案
MainActivity例如以下: package cc.cc; import android.app.Activity; import android.content.Intent; import ...
- Arcgis Engine(ae)接口详解(2):featureClass查询
//属性查询~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ //IQueryFilter代表查询条件,QueryFilterClass代表只限于属性查询(就是没有空间查询) ...
- Entity Framework 6 Code First系列1: 实体类1:1配置
从4.1版本开始,EF开始支持Code First模式,值得注意的是Code First不是和DataBase First或Model First平级的概念,而是和EDM平级的概念.使用Code Fi ...
- CString转换成char *字符串问题
buf = (LPSTR)(LPCTSTR)str; ==> buf 显示的是第一个字符 strcpy(pNumber,strNumber); ==> e ...
- 字符串函数---strcat()与strncat具体解释及实现
一.strcat()与strncat() strcat():strcat(dest,src); strcat把src所指向的字符加入到dest结尾处(覆盖原dest结尾处的'\0').并 ...
- because joins aren’t as important.
“MongoDB wasn’t designed in a lab. We built MongoDB from our own experiences building large-scale, h ...