zoukankan      html  css  js  c++  java
  • A. Treasure Hunt Codeforces 线性代数

    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
    #include<iostream>
    #include<cstdio>
    #include<cmath>
    #include<cstring>
    #include<sstream>
    #include<algorithm>
    #include<queue>
    #include<deque>
    #include<iomanip>
    #include<vector>
    #include<cmath>
    #include<map>
    #include<stack>
    #include<set>
    #include<fstream>
    #include<memory>
    #include<list>
    #include<string>
    using namespace std;
    typedef long long LL;
    typedef unsigned long long ULL;
    #define MAXN 1000009
    #define N 21
    #define MOD 1000000
    #define INF 1000000009
    const double eps = 1e-8;
    const double PI = acos(-1.0);
    inline int sgn(double t)
    {
        if (abs(t - floor(t)) < eps)
            return 0;
        else
            return 1;
    }
    int main()
    {
        double x1, y1, x2, y2, a, b;
        cin >> x1 >> y1 >> x2 >> y2;
        double x = abs(x2 - x1), y = abs(y2 - y1);
        cin >> a >> b;
        if (sgn((double)(x/2/a + y/2/b)) == 0 &&
            sgn((double)(y/2/b - x/2/a)) == 0)
            printf("YES
    ");
        else
            printf("NO
    ");
    }
  • 相关阅读:
    content type
    存储过程查询并插入到临时表
    jdk 生成证书
    sql 表值函数-将一个传入的字符串用2中分隔符拆分成临时表
    sql 把一个用逗号分隔的多个数据字符串变成一个表的一列
    sql 分隔字符串函数
    md5 加密
    SQL语句的使用
    WINDOW的cmd的命令【转载】
    zookeeper安装
  • 原文地址:https://www.cnblogs.com/joeylee97/p/7039768.html
Copyright © 2011-2022 走看看