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 ...
随机推荐
- TypeScript基本知识(为学习AngularJS2框架做个小铺垫)
学习angularjs2框架,需要了解一些TypeScript知识点,基本了解下面这几个知识点学习AngularJS2 就够用了 1.TypeScript 1.1显示类型的定义 TypeScript类 ...
- HTML基础知识入门
好的,我们开始吧,打开Eclipse,新建一个项目,就叫做Base吧,基础班的意思.注意哦,要建一个JavaWeb项目.右键,new,Dynamic Web Project,如果出来的菜单项没有,就点 ...
- [刷题]算法竞赛入门经典(第2版) 5-11/UVa12504 - Updating a Dictionary
题意:对比新老字典的区别:内容多了.少了还是修改了. 代码:(Accepted,0.000s) //UVa12504 - Updating a Dictionary //#define _XieNao ...
- [刷题]ACM/ICPC 2016北京赛站网络赛 第1题 第3题
第一次玩ACM...有点小紧张小兴奋.这题目好难啊,只是网赛就这么难...只把最简单的两题做出来了. 题目1: 代码: //#define _ACM_ #include<iostream> ...
- JavaScript开发中几个常用知识点总结
最近在做项目的时候自己写了一些JavaScipt代码,于是自己又进行简单的查阅资料整理了一下,发现了如下几个比较有用的知识点: 1.三种声明函数的方式 2.jQuery $(document).rea ...
- Java内存模型四
volatile的特性 当我们声明共享变量为volatile后,对这个变量的读/写将会很特别.理解volatile特性的一个好方法是:把对volatile变量的单个读/写,看成是使用同一个锁对这些单个 ...
- System.load 与 System.loadLibrary 的使用
相同点 它们都可以用来装载库文件,不论是JNI库文件还是非JNI库文件. 在任何本地方法被调用之前必须先用这个两个方法之一把相应的JNI库文件装载. System.load System.load 参 ...
- 从编译器角度理解C++中的引用和指针
欲分析指针和引用,则要分析变量名和地址之间的关系(不管你理解还是不理解,无论你是从老师那里听到的,还是网上看到的,应该都知道两句话:1. 指针就是地址,2.引用就是给变量起个别名) 所以我们就要来分析 ...
- TP框架 命名空间 与第三方类
命名空间 相当于虚拟目录 所有类文件都放在虚拟目录 功能:实现自动加载类 TP框架的命名空间要更复杂 内容=> 命名空间中定义和使用 都用\1初始命名空间 相当于 根目录 如:Library文件 ...
- C# 字典 Dictionary
原文地址http://www.cnblogs.com/txw1958/archive/2012/11/07/csharp-dictionary.html 侵删



