zoukankan      html  css  js  c++  java
  • hdu 5054

    Alice and Bob

    Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
    Total Submission(s): 747    Accepted Submission(s): 549


    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:

    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
     
    题意:Bob(0,0) 和 ALice(n,m) 要在(x,y)点汇合。问是否可能?
    #include <iostream>
    #include <stdio.h>
    #include <string.h>
    #include <algorithm>
    #include <map>
    using namespace std;
    int main()
    {
        int a,b,c,d;
        while(scanf("%d%d%d%d",&a,&b,&c,&d)!=EOF){
            if(a-c==c&&b-d==d) printf("YES
    "); ///Bob要从 0,0 走到 (x,y) Alice 要从 (n,m)走到(n-x,m-y)
                                                /// x = n - x,y = m-y;
            else printf("NO
    ");
        }
        return 0;
    }
  • 相关阅读:
    Zend框架2入门(二) (转)
    Zend框架2入门(一) (转)
    PHP Strict standards:Declaration of … should be compatible with that of…(转)
    ::符号
    mysql查询今天,昨天,近7天,近30天,本月,上一月数据的方法(转)
    php 获取今日、昨日、上周、本月的起始时间戳和结束时间戳的方法(转)
    PHP5.4新特性(转)
    PHP5.4的变化关注---What has changed in PHP 5.4.x(转)
    关于PHP的curl开启问题 (转)
    安装apache重启的时候,报错端口被占用,错误1
  • 原文地址:https://www.cnblogs.com/liyinggang/p/5649245.html
Copyright © 2011-2022 走看看