Description































Input









































Output
Sample Input
2 3 2 2 3 3 1 1
Sample Output
1 2
Hint
Case 1 :

You can split the floor into five 


apartments. The answer is 1. Case 2:

You can split the floor into three 


apartments and two 


apartments. The answer is 2.

If you want to split the floor into eight 


apartments, it will be unacceptable because the apartment located on (2,2) can‘t have windows.
#include <iostream>
#include<algorithm>
#define INF 0x3f3f3f3f
using namespace std;
int main()
{
int n, m, x, y, ans;
while(~scanf( "%d%d%d%d", &n, &m, &x, &y ))
{
if(n>m) swap( n, m ), swap( x, y );//调整,非常重要,注意x和n要一起旋转
if(n == m && n & 1 && x == y && x == (n + 1) / 2)
ans = x - 1;
else
{
int m1 = min( y, m - y + 1 );
int m2 = max( x - 1, n - x );
ans = min( m1, m2 );
ans = max( ans, (n + 1) / 2 );
}
printf( "%d\n", ans );
}
return 0;
}这道题重在思维,代码其实非常简单。一开始的调整动作是非常有必要的,也是此题精髓所在。版权声明:本文为博主原创文章,未经博主允许不得转载。
原文地址:http://blog.csdn.net/maxichu/article/details/47763757