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;
}



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