Treasure Hunt
Captain Bill the Hummingbird and his crew recieved an interesting challenge offer. Some stranger gave them a map, potion of teleportation and said that only this potion might help them to reach the treasure.
Bottle with potion has two values x and y written on it. These values define four moves which can be performed using the potion:
Map shows that the position of Captain Bill the Hummingbird is (x1, y1) and the position of the treasure is (x2, y2).
You task is to tell Captain Bill the Hummingbird whether he should accept this challenge or decline. If it is possible for Captain to reach the treasure using the potion then output "YES", otherwise "NO" (without quotes).
The potion can be used infinite amount of times.
The first line contains four integer numbers x1, y1, x2, y2 ( - 105 ≤ x1, y1, x2, y2 ≤ 105) — positions of Captain Bill the Hummingbird and treasure respectively.
The second line contains two integer numbers x, y (1 ≤ x, y ≤ 105) — values on the potion bottle.
Print "YES" if it is possible for Captain to reach the treasure using the potion, otherwise print "NO" (without quotes).
0 0 0 6
2 3
YES
1 1 3 6
1 5
NO
In the first example there exists such sequence of moves:
— the first type of move
— the third type of move
题解:
做了两次codeforces之后发现上面的题目很多没有看起来那么复杂,实际上只需要判断一下是否可以整除并且整除之后奇偶性是不是一样的就可以了。
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<ctime>
#include<vector>
using namespace std;
int x,x2,y,y2,a,b;
int main()
{
int i,j;
cin>>x>>y>>x2>>y2;
cin>>a>>b;
i=abs(x2-x);j=abs(y2-y);
if(i%a==&&j%b==&&((i/a)%==(j/b)%))cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
Treasure Hunt的更多相关文章
- zoj Treasure Hunt IV
Treasure Hunt IV Time Limit: 2 Seconds Memory Limit: 65536 KB Alice is exploring the wonderland ...
- POJ 1066 Treasure Hunt(线段相交判断)
Treasure Hunt Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 4797 Accepted: 1998 Des ...
- ZOJ3629 Treasure Hunt IV(找到规律,按公式)
Treasure Hunt IV Time Limit: 2 Seconds Memory Limit: 65536 KB Alice is exploring the wonderland ...
- POJ 1066 Treasure Hunt(相交线段&&更改)
Treasure Hunt 大意:在一个矩形区域内.有n条线段,线段的端点是在矩形边上的,有一个特殊点,问从这个点到矩形边的最少经过的线段条数最少的书目,穿越仅仅能在中点穿越. 思路:须要巧妙的转换一 ...
- poj1066 Treasure Hunt【计算几何】
Treasure Hunt Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 8192 Accepted: 3376 Des ...
- zoj 3629 Treasure Hunt IV 打表找规律
H - Treasure Hunt IV Time Limit:2000MS Memory Limit:65536KB 64bit IO Format:%lld & %llu ...
- ZOJ 3626 Treasure Hunt I 树上DP
E - Treasure Hunt I Time Limit:2000MS Memory Limit:65536KB Description Akiba is a dangerous country ...
- 湖南大学ACM程序设计新生杯大赛(同步赛)I - Piglet treasure hunt Series 1
题目描述 Once there was a pig, which was very fond of treasure hunting. The treasure hunt is risky, and ...
- 【树形dp】Treasure Hunt I
[ZOJ3626]Treasure Hunt I Time Limit: 2 Seconds Memory Limit: 65536 KB Akiba is a dangerous coun ...
随机推荐
- SectionIndexer 利用系统的控件,制作比较美观的侧栏索引控件
如上图所示,右侧的索引是系统提供的,具体使用方法,请搜索: SectionIndexer 相关的资料进行开发.
- CSS清除浮动各种方法
当容器的高度为auto,且容器的内容中有浮动(float为left或right)的元素,在这种情况下,容器的高度不能自动伸长以适应内容的高度,使得内容溢出到容器外面而影响(甚至破坏)布局的现象.这个现 ...
- 分针网——每日分享: jquery选择器的用法
jQuery选择器是jQuery库的一大特色,用这些选择器不但可以省去繁琐的JavaScript 书写方式,还可以节省时间和效率,正是有这些jQuery选择器,才让我们更容易的操作JavaScript ...
- Java中实现String.padLeft和String.padRight
因为习惯了C#中的padLeft和padRight,接触Java后突然失去这两个功能,觉得别扭,就试着实现了这两个方法. Java中String.format()中带有字符串对齐功能如下: Syste ...
- Struts2之 OGNL表达式和值栈
技术分析之OGNL表达式概述(了解) 1. OGNL是Object Graphic Navigation Language(对象图导航语言)的缩写 * 所谓对象图,即以任意 ...
- ER模型的学习
(计应154兰家才)在建立表后开始了学习的第一步,了解数据库的基本知识,就以建立bbs论坛为标准学习er模型,首先建立了4个表分别是BBSReply,BBSSection,BBSTopic,BBSUs ...
- windows 上优雅的安装 node 和 npm
windows 的一键安装包,应该是最简单的 node 安装方式. 其实很多软件,拷贝过来就可以运行,根本不需要所谓的"安装"过程. 新建一个目录专门了管理 node 和 npm ...
- 《安卓网络编程》之第三篇 使用Apache接口
在Android系统中,提供了一下三种通信接口: 标准的Java 接口:java.net Apache接口:org.apache.http Android网络接口:android.net.http 在 ...
- python求职Top10城市,来看看是否有你所在的城市
前言 从智联招聘爬取相关信息后,我们关心的是如何对内容进行分析,获取用用的信息. 本次以上篇文章“5分钟掌握智联招聘网站爬取并保存到MongoDB数据库”中爬取的数据为基础,分析关键词为“python ...
- 修改node来增加自定义工具命令
如何通过node创建自定义cmd命令 一.命令功能的实现 1.将自己的自定义工具的文件夹放到当前使用的 node 的安装目录下的 node_modules 文件夹下面: 2.回到node安装目录下复制 ...