hdu 5301 Buildings
来源:互联网 发布:静态路由协议端口号 编辑:程序博客网 时间:2024/05/16 09:41
题解 && 总结:
1.检测全面思考问题的能力
2.以后再碰到这样的问题,在纸上清楚地写出所有的情况,做到不重不漏
3.一道题目,如果连续三次没有AC便放手做其他的题目,不再纠结,争取平时做题也做到1A
4.不轻视简单的问题,认真对待每一个问题
#include<iostream>#include<cstring>#include<cstdio>#include<algorithm>using namespace std;#define MAXN 10000int 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; }}
0 0
- HDU 5301 - Buildings(技巧)
- hdu 5301 Buildings
- HDU - 5301 Buildings
- hdu 5301 Buildings
- HDU 5301 Buildings
- HDU 5301Buildings
- HDU 5301 Buildings
- hdu 5301 Buildings
- hdu 5301 Buildings
- hdu 5301(枚举) Buildings
- HDU 5301 Buildings
- hdu 5301 Buildings
- HDU 5301 Buildings (乱搞)
- 4302: Hdu 5301 Buildings
- HDU 5301 Buildings(思维题)
- HDU 5301 Buildings(找规律)
- HDU 5301 Buildings(思维)
- HDU 5301 Buildings(机智)
- 左侧菜单栏如何延伸到页面最底部
- 【poj2184】【Cow Exhibition】
- 对fork()函数的理解
- 欢迎使用CSDN-markdown编辑器
- python3入门之字典
- hdu 5301 Buildings
- ios开发--UIGestureRecognizer
- iOS开发多线程篇—GCD介绍
- ehcache时如何持久化数据到磁盘,并且在应用服务器重启后不丢失数据
- NOT IN和NOT EXISTS小区别
- Android弹出框效果——popupwindow
- 最小二乘法(自我理解+自我熟悉)(1)
- [leetcode-31]Next Permutation(C)
- 附近地点搜索解决方案