https://vjudge.net/contest/218366#problem/B
要不是在数学题专题里,我估计就盲目搜索了。10^18范围1s应该过不去。
再细看能感觉到是gcd的变形,但是具体结论说不上来。
推导参考:https://blog.csdn.net/LuRiCheng/article/details/54729531
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #include<cstdlib> 6 #include<cmath> 7 #include<vector> 8 #include<stack> 9 #include<queue> 10 #define lson l, m, rt<<1 11 #define rson m+1, r, rt<<1|1 12 #define IO ios::sync_with_stdio(false);cin.tie(0); 13 #define INF 0x3f3f3f3f 14 #define MAXN 100010 15 const int MOD=1e9+7; 16 typedef long long ll; 17 using namespace std; 18 ll n, a, b, x, y; 19 ll gcd(ll a, ll b) 20 { 21 if(a%b == 0) 22 return b; 23 return gcd(b, a%b); 24 } 25 int main() 26 { 27 IO; 28 cin >> n; 29 while(n--){ 30 cin >> a >> b >> x >> y; 31 if(gcd(a, b) == gcd(x, y)) 32 cout << "Yes" << endl; 33 else 34 cout << "No" << endl; 35 } 36 return 0; 37 }