您的位置:首页 > 产品设计 > UI/UE

hdu 5301 Buildings

2015-07-29 14:25 316 查看
题解 && 总结:

1.检测全面思考问题的能力

2.以后再碰到这样的问题,在纸上清楚地写出所有的情况,做到不重不漏

3.一道题目,如果连续三次没有AC便放手做其他的题目,不再纠结,争取平时做题也做到1A

4.不轻视简单的问题,认真对待每一个问题

#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 10000
int n,m,x,y;
int solve()
{
    if(n == m && (n & 1) && (n + 1) / 2 == x && x == y)
        return n / 2;
    if(m == 1 || n == 1)return 1;
    if(x > n / 2)x = n - x + 1;
    if(y > m / 2)y = m - y + 1;
    int ans1 = min(max(x,n - x),max(y,m - y));
    int ans2 = min(max(x,(m + 1) / 2),max(y,(n + 1) / 2));
    int ans3 = max(x - 1,max(m - y,(m + 1) / 2));
    int ans4 = max(y - 1,max(n - x,(n + 1) / 2));
    return min(min(ans1,ans2),min(ans3,ans4));
}
int main()
{
    while(cin >> n >> m >> x >> y)
    {
        int ans = solve();
        cout << ans << endl;
    }
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: