hdu 1577【WisKey的眼神】
2012-05-20 21:44
295 查看
代码如下:
#include <cstdio> #include <cmath> #include <algorithm> void solve(); int L,sx,sy,px,py; int main() { while(scanf("%d",&L),L) { scanf("%d%d%d%d",&sx,&sy,&px,&py); if(py > L || px > L || py < -L || px < -L) { printf("Out Of Range\n"); continue; } solve(); } return 0; } void solve() { int a = px - sx; int b = py - sy; if(a == 0) { if(abs(b) <= 1) { printf("Yes\n"); } else { printf("No\n"); } return; } if(b == 0) { if(abs(a) <= 1) { printf("Yes\n"); } else { printf("No\n"); } return; } if(abs(a) == 1 && abs(b) == 1) { printf("Yes\n"); return; } int minn = std::min(sx,px); int maxm = std::max(sx,px); for(int i = minn + 1;i < maxm;i ++) { int temp = b * i + a * sy - b * sx; if(temp % a == 0) { if(temp / a < std::max(sy,py) && temp / a > std::min(sy,py)) { printf("No\n"); return; } } } printf("Yes\n"); }
相关文章推荐
- HDU 1577 WisKey的眼神 (GCD求直线上的点数)
- HDU:1577 WisKey的眼神
- hdu 1577 WisKey的眼神
- I - WisKey的眼神 HDU - 1577
- HDU 1577 WisKey的眼神
- hdu 1577 WisKey的眼神 (数学几何)
- hdu 1577 WisKey的眼神
- 【hdu】1577 WisKey的眼神(两个点之间是否存在整数坐标)
- I - WisKey的眼神 HDU - 1577【数学】【思维】
- hdu 1577 WisKey的眼神(gcd判断直线上的整点)
- WisKey的眼神(hdu 1577)
- 杭电OJ题 1577 WisKey的眼神 解题报告
- 【hdoj】1577 WisKey的眼神
- WisKey的眼神 HDU - 1577 gcd
- HDU1577--WisKey的眼神(扩展欧几里德)
- HDU1577 WisKey的眼神
- WisKey的眼神
- HDU1577-WisKey的眼神
- hdu 1577
- hdu1577 WisKey的眼神