题意:给n*m的矩形区域,去除其中1*1的方块,然后用不同矩形块填充整个矩形区域,求需要的矩形块最大面积的最小值。
思路:因为要考虑到每一个矩形都要与边界接触,画下图就可以看出去除方块的四周就是关键点,为了最小值必定宽为1。
然后就是讨论围绕去除方块的四周进行讨论了。
推荐这篇博客(有图号理解):https://blog.csdn.net/controlbear/article/details/52014702
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<math.h>
#include<string>
#include<vector>
#include<cstdio>
#include<time.h>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<string.h>
#include<algorithm>
#define ll long long
#define PI acos(-1.0)
using namespace std;
int main()
{
int n,m,x,y;
while(scanf("%d%d%d%d",&n,&m,&x,&y)!=EOF)
{
if(n>m)
{
swap(n,m);
swap(x,y);
}
if(n==m&&x==y&&n%2==1&&x==(n+1)/2)
{
int ans=(n+1)/2;
ans=ans-1;
cout<<ans<<endl;
continue;
}
int ans;
int w1=min(x-1,min(y,m-y+1));
int w2=min(n-x,min(y,m-y+1));
ans=max((n+1)/2,max(w1,w2));
cout<<ans<<endl;
}
}