Treasure Hunt

Treasure Hunt
time limit per test 1 second
memory limit per test 256 megabytes
input standard input
output standard output

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.

Input

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.

Output

Print "YES" if it is possible for Captain to reach the treasure using the potion, otherwise print "NO" (without quotes).

Examples
input
0 0 0 6
2 3
output
YES
input
1 1 3 6
1 5
output
NO
Note

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==0&&j%b==0&&((i/a)%2==(j/b)%2))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

 

 

 

posted @ 2017-06-16 09:36  kakakakakaka  阅读(385)  评论(0编辑  收藏  举报

Never forget why you start

//鼠标爆炸特效