码迷,mamicode.com
首页 > 其他好文 > 详细

HDU 5054 Alice and Bob(数学)

时间:2014-09-29 20:54:41      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:数学   hdu   bestcoder   

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5054



Problem Description
Bob and Alice got separated in the Square, they agreed that if they get separated, they‘ll meet back at the coordinate point (x, y). Unfortunately they forgot to define the origin of coordinates and the coordinate axis direction. Now, Bob in the lower left corner of the Square, Alice in the upper right corner of the the Square. Bob regards the lower left corner as the origin of coordinates, rightward for positive direction of axis X, upward for positive direction of axis Y. Alice regards the upper right corner as the origin of coordinates, leftward for positive direction of axis X, downward for positive direction of axis Y. Assuming that Square is a rectangular, length and width size is N * M. As shown in the figure:
bubuko.com,布布扣

Bob and Alice with their own definition of the coordinate system respectively, went to the coordinate point (x, y). Can they meet with each other ? 
Note: Bob and Alice before reaching its destination, can not see each other because of some factors (such as buildings, time poor).
 
Input
There are multiple test cases. Please process till EOF. Each test case only contains four integers : N, M and x, y. The Square size is N * M, and meet in coordinate point (x, y). ( 0 < x < N <= 1000 , 0 < y < M <= 1000 ).
 
Output
If they can meet with each other, please output "YES". Otherwise, please output "NO".
 
Sample Input
10 10 5 5 10 10 6 6
 
Sample Output
YES NO
 
Source


官方题解:

bubuko.com,布布扣


代码如下:

#include <cstdio>
int main()
{
    int n, m;
    int x, y;
    while(~scanf("%d%d%d%d",&n,&m,&x,&y))
    {
        if(x*2==n && y*2==m)
            printf("YES\n");
        else
            printf("NO\n");
    }
    return 0;
}


HDU 5054 Alice and Bob(数学)

标签:数学   hdu   bestcoder   

原文地址:http://blog.csdn.net/u012860063/article/details/39674659

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!