就是等价于一个4个元2个方程判断解的存在性。。。

然后乱搞吧。。。(貌似叫裴蜀定理?)

 

 1 /**************************************************************
 2     Problem: 2299
 3     User: rausen
 4     Language: C++
 5     Result: Accepted
 6     Time:148 ms
 7     Memory:804 kb
 8 ****************************************************************/
 9  
10 #include <cstdio>
11 #include <algorithm>
12   
13 using namespace std;
14 typedef long long ll;
15 ll T, a, b, x, y, d;
16   
17 inline ll read(){
18     ll x = 0, sgn = 1;
19     char ch = getchar();
20     while (ch < '0' || ch > '9'){
21         if (ch == '-') sgn = -1;
22         ch = getchar();
23     }
24     while (ch >= '0' && ch <= '9'){
25         x = x * 10 + ch - '0';
26         ch = getchar();
27     }
28     return sgn * x;
29 }
30   
31 ll gcd(ll a, ll b){
32     return a ? gcd(b % a, a) : b;
33 }
34   
35 bool check(ll a, ll b){
36     return a % d == 0 && b % d == 0;
37 }
38   
39 int main(){
40     T = read();
41     while (T--){
42         a = read(), b = read(), x = read(), y = read();
43         d = gcd(a, b) * 2;
44         if (check(x, y) || check(x - a, y - b) || check(x - b, y - a) || check(x - a - b, y - a - b))
45             printf("Y\n");
46         else printf("N\n");
47     }
48     return 0;
49 }
View Code

 

posted on 2015-03-17 19:44  Xs酱~  阅读(225)  评论(0编辑  收藏  举报