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
",ans);
    }
    return 0;
}
原文地址:https://www.cnblogs.com/keyboarder-zsq/p/5934395.html