hdu 5301 Buildings
2015-08-14 10:07
295 查看
题目链接:
http://acm.hdu.edu.cn/showproblem.php?pid=5301
解题思路:
官方题解:
AC代码:
按照官方题解if顺序,很遗憾,并没有ac。。。后来看了别人的题解。。。才明白只能是:
AC代码:
http://acm.hdu.edu.cn/showproblem.php?pid=5301
解题思路:
官方题解:
AC代码:
按照官方题解if顺序,很遗憾,并没有ac。。。后来看了别人的题解。。。才明白只能是:
if(n % 2 && n == m && x == y && x == (n+1)/2) answer = n / 2; else if(x == ans || x == ans + 1 || y == 1 || y == m) answer = ans; else if(min(left, right) > ans) answer= min(max(up,down),min(left,right)); else answer = ans;
AC代码:
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int main(){
int n,m,x,y;
while(scanf("%d%d%d%d",&n,&m,&x,&y) != EOF){
if(n > m){
swap(n,m);
swap(x,y);
} //n<=m
int ans = (n + 1) / 2,answer;
int left = y,right = m - y+1;
int up = x-1,down = n-x;
if(n % 2 && n == m && x == y && x == (n+1)/2) answer = n / 2; else if(x == ans || x == ans + 1 || y == 1 || y == m) answer = ans; else if(min(left, right) > ans) answer= min(max(up,down),min(left,right)); else answer = ans;
printf("%d\n",answer);
}
return 0;
}
相关文章推荐
- 创建型模式:建造者模式(Builder Pattern)
- Havok_2014-1-0_Pc_Xs_User_Guide(2.3.2-一般监听器)
- UITextField-设置大全-placeholder左上角显示
- hdu - 3836 Equivalent Sets(强连通)
- popupwindow实现炫酷动画UI
- SSIS 错误代码 DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER(0xC0202009)
- systemverilog中$value$plusargs的用法
- POJ 3080 Blue Jeans
- Windows Server 2016 build 10514系统截图曝光
- java.lang.IllegalArgumentException: Illegal character in query at index ...解决办法
- Value Stewardship Over Showmanship
- UINavigationBar的系统渲染方式
- 用Ionic框架+HBuilder开发的一些观察
- UIScrollView+UIPageControl
- 根据map的value值排序并输出
- h5+ mui笔记
- h5+ mui笔记
- String,StringBuffer,StringBuilder区别总结
- ueditor不自动加P解决方法
- iOS项目中的version和build