其他分享
首页 > 其他分享> > [HAOI2011]向量(裴蜀定理)

[HAOI2011]向量(裴蜀定理)

作者:互联网

//优化
#pragma GCC optimize(2)
//C
#include<string.h>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
//C++
//#include<unordered_map>
#include<algorithm>
#include<iostream>
#include<istream>
#include<iomanip>
#include<climits>
#include<cstdio>
#include<string>
#include<vector>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<set>
//宏定义
#define N 1010
#define DoIdo main
//#define scanf scanf_s
#define it set<ll>::iterator
//定义+命名空间
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 998244353;
const ll INF = 1e18;
const int maxn = 1e6 + 10;
using namespace std;
//全局变量
//函数区
ll max(ll a, ll b) { return a > b ? a : b; }
ll min(ll a, ll b) { return a < b ? a : b; }
ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
//主函数
int DoIdo() {
 
    ios::sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
 
    int T;
    cin >> T;
 
    while (T--) {
        ll a, b, x, y;
        cin >> a >> b >> x >> y;
 
        ll g = gcd(2 * a, 2 * b);
        bool jg = 0;
        if (x % g == 0 && y % g == 0) jg = 1;
        if ((x + a) % g == 0 && (y + b) % g == 0) jg = 1;
        if ((x + b) % g == 0 && (y + a) % g == 0) jg = 1;
        if ((x + a + b) % g == 0 && (y + a + b) % g == 0) jg = 1;
        if (jg) cout << "Y" << endl;
        else cout << "N" << endl;
    }
    return 0;
}
//分割线---------------------------------QWQ
/*
 
 
 
*/

标签:裴蜀,y1,2a,2b,small,cases,equiv,向量,HAOI2011
来源: https://blog.csdn.net/qq_45739057/article/details/106226538