0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-27 13:56:26 +00:00

P2520 [HAOI2011]向量

https://www.luogu.com.cn/record/89364875
This commit is contained in:
Baoshuo Ren 2022-10-10 18:55:10 +08:00
parent 63eace5d98
commit 77bdd51811
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A

30
Luogu/P2520/P2520.cpp Normal file
View File

@ -0,0 +1,30 @@
#include <iostream>
#include <algorithm>
using std::cin;
using std::cout;
const char endl = '\n';
int t, a, b, x, y;
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> t;
while (t--) {
cin >> a >> b >> x >> y;
int g = std::__gcd(a, b) * 2;
a %= g, b %= g, x %= g, y %= g;
auto check = [&](int x, int y) -> bool {
return x % g == 0 && y % g == 0;
};
cout << (check(x, y) || check(x + a, y + b) || check(x + b, y + a) || check(x + a + b, y + a + b) ? "Y" : "N") << endl;
}
return 0;
}