1002 Buildings
特别拐弯抹角的平面几何模拟计算
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
const int maxn=210;
const int inf=0x7fffffff;
const double eps=1e-3;
int N,M;
int main()
{
int x,y;
while(~scanf("%d%d%d%d",&N,&M,&x,&y))
{
if (M<N)
{
swap(N,M);
swap(x,y);
}
int t0=(N+1)>>1;
int up=x-1;
int down=N-x;
int left=y-1;
int right=M-y;
//cout<<t0<<endl;
if ((N&1)&&N==M&&x==y&&x==(N+1)/2)
printf("%d\n",t0-1);
/*else if (min(up,down)>t0)
printf("%d\n",min(max(left,right),min(up,down)));*/
else
{
x=min(x,N-x+1);
y=min(y,M-y+1);
t0=max(t0,min(N-x,y));
t0=min(t0,(M+1)/2);
printf("%d\n",t0);
}
}
return 0;
}