归纳所有操作,然后==裴蜀定理判判。
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; long long t,x,y,a,b,d; long long gcd(long long a,long long b) { if (b==0) return a; return gcd(b,a%b); } bool judge(long long x,long long y) { if ((x%d==0) && (y%d==0)) return true; return false; } int main() { scanf("%lld",&t); for (long long i=1;i<=t;i++) { scanf("%lld%lld%lld%lld",&a,&b,&x,&y); d=gcd(2*a,2*b); if ((judge(x,y)) || (judge(x+a,y+b)) || (judge(x+b,y+a)) || (judge(x+a+b,y+a+b))) printf("Y "); else printf("N "); } return 0; }