Educational Codeforces Round 23 A. 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:

  1.  — the first type of move
  2.  — the third type of move

这道题目的意思就是给定一个起点一个终点座标,然后用题目中给的四种方法走任意次(X,Y的值在下一行输入)能从起点走到终点就输出YES,反之NO

其实也就是用终点的座标减去起点座标求一个x和y的绝对值

然后这个值必须是X,Y的倍数(对X,Y去余为0)

然后必须都是偶数倍,如果是奇数倍则不能x,y同时等于X,Y,

只有偶数的时候如果哪个超过了,可以用偶数次的时间来等另一个。所以必须是偶数倍

代码如下:

#include<bits/stdc++.h>
#include<iostream>
using namespace std;
int main()
{
    int x1,y1,x2,y2,x,y,x3,y3;
    cin>>x1>>y1>>x2>>y2;
    x3=abs(x1-x2);y3=abs(y1-y2);
    cin>>x>>y;
    //why
    if(x3%x==0&&y3%y==0&&(x3/x)%2==(y3/y)%2)
    {
        cout<<"YES";
    }
    else cout<<"NO";
    return 0;
}



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章