HDU 5054 Alice and Bob——BestCoder Round #11(div.2)
2015-08-31 13:05
302 查看
Alice and Bob
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)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
Source
BestCoder Round #11 (Div. 2)
/****************************************************/
出题人的解题思路:
两个人的坐标系不同,如果都走到(x,y)能够碰面的话,只有一种可能:在广场矩形的中心位置。 即: 2*x == N 并且 2*y == M。
题意:如下图所示,Bob在广场的左下角,对于他来说,往右是X轴正方向,往上是Y轴正方向;而Alice在广场的右上角,对于她来说,往左是X轴正方向,往下是Y轴正方向。他们要在各自的坐标系中到达某点(x,y),问是否存在这样的点,两人能够相遇
解题思路:我们以Bob所在点为坐标原点建立坐标系,那么
化简可得
因此我们只需判断一下给定的n、m、x、y是否满足上式即可
#pragma comment(linker, "/STACK:1024000000,1024000000") #include<stdio.h> #include<string.h> #include<stdlib.h> #include<queue> #include<stack> #include<math.h> #include<vector> #include<map> #include<set> #include<stdlib.h> #include<cmath> #include<string> #include<algorithm> #include<iostream> #define exp 1e-10 using namespace std; const int N = 105; const int inf = 2147483647; const int mod = 2009; int main() { int n,m,x,y; while(~scanf("%d%d%d%d",&n,&m,&x,&y)) { if(n==2*x&&m==2*y) puts("YES"); else puts("NO"); } return 0; }菜鸟成长记
相关文章推荐
- 微擎分页
- Java获取数据库的表中各字段的字段名等相关信息-很详细
- linux环境配置
- 有关于SQL SERVER的事务(随手笔记)
- Spring中Quartz调度器的使用 ----继承QuartzJobBean,不继承QuartzJobBean两种方式
- Spring MVC Controller 多方法
- WebStorm使用less
- INSTALL_FAILED_CONFLICTING_PROVIDER错误解决方法
- 将 paired count 和unpaired count 相加
- PHP ASCII码与字符串的相互转换
- 1041. Be Unique (20)
- BZOJ 3224: Tyvj 1728 普通平衡树 treap
- Android bitmap的拷贝以及平移旋转缩放等效果
- Spring+Quartz实现定时任务的配置方法--Cron表达式解释
- dom4j 读取某个元素的某个属性
- 零基础学python-10.1 序列赋值高级应用
- 零基础学python-10.1 序列赋值高级应用
- Maven的Archetype简介
- 破解wifi
- Sublime Text 3安装与使用