欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Timus 1286

程序员文章站 2024-03-16 16:32:04
...

分析

详见这篇非常好的分析
AC代码:


#include <bits/stdc++.h>

using namespace std;

#define LL long long

LL gcd(LL a, LL b){
    return b ? gcd(b, a%b):a;
}

int main(){
    bool ans = true;
    LL p, q;
    LL x1, y1, x2, y2;
    LL dx, dy;
    cin >>p >>q;
    cin >>x1 >>y1 >>x2 >>y2;

    dx = x2-x1, dy = y2-y1;
    LL gd = gcd(p, q);

    if(dx % gd!=0 || dx%gd !=0){
        ans = false;
    }
    else{
        dx /= gd, dy /= gd;
        p /= gd, q /= gd;
        if(abs(dx%2) == abs(dy%2) || (abs(dx%2) != abs(dy%2) && abs(p%2) != abs(q%2)) )
            ans = true;
        else
            ans = false;
    }

    if(ans ) cout <<"YES\n";
    else cout <<"NO\n";

    return 0;
}