zoukankan      html  css  js  c++  java
  • 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;
    }
  • 相关阅读:
    linux---shell数组
    linux---shell传递参数
    Windows mysql免安装版配置。(版本号-5.6.45);
    contos 6.9 和 centos7 配置docker?
    数据库表的演化过程
    docker简单介绍。
    Linux 配置 mycat 和 分库分表配置。
    Linux 配置mysql 免安装版。
    mycat 简单介绍
    kibana 对es的简单操作。
  • 原文地址:https://www.cnblogs.com/huangdalaofighting/p/7025917.html
Copyright © 2011-2022 走看看