hdu 5301 Buildings
2015-07-29 14:25
316 查看
题解 && 总结:
1.检测全面思考问题的能力
2.以后再碰到这样的问题,在纸上清楚地写出所有的情况,做到不重不漏
3.一道题目,如果连续三次没有AC便放手做其他的题目,不再纠结,争取平时做题也做到1A
4.不轻视简单的问题,认真对待每一个问题
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; } }
相关文章推荐
- 游戏UI库
- Implement Queue using Stacks
- ios开发--UIGestureRecognizer
- iOS-UI-05 导航控制器的使用 UINavigationController
- iOS-UI-滚动视图2—分页查看功能
- 写在Demo战斗系统之前,先用原型工具做套UI第二篇-人物选择界面制作
- IOS GCD queue group
- 无法使用以下搜索标准找到 X.509 证书: StoreName“My”、StoreLocation“LocalMachine”、FindType“FindBySubjectName”、FindValue“MyWebSite”。
- easyui 获取指定列的值,格式化该列的值的实例
- iOS中添加UITapGestureRecognizer手势识别后,UITableView的didSelectRowAtIndexPath失效
- VisualSVN错误 Cannot query proxy blanket解决办法
- UISegmentControl 和UIslider
- QQuickImageProvider在QML设计中的应用
- 【干货】jsMind思维导图整合Easyui的右键菜单
- iOS UITableView删除cell分割线
- mediawiki和confluence
- UITapGestureRecognizer会屏蔽掉Button的点击事件
- 从ValueType讨论c#的值类型系统
- 玩转Android--UI篇--PreferenceActivity(开启wifi和音乐等)
- UIImage的2种加载方式