D. X-Magic Pair
一道数学题,我们让a>=b,那么如果x在a到a%b之间就可以通过a-n*b得到
然后辗转相余
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 998244353;
const int N = 2e5 + 9;
map<int, int> mp;
signed main()
{int t;cin >> t;while (t--){mp.clear();int a, b, x;cin >> a >> b >> x;int ff = 1;while (1){int c;if (a >= b){c = a % b;if (x % b == c && x <= a)ff = 0;a = c;}else{c = b % a;if (x % a == c && x <= b)ff = 0;b = c;}if (a==0||b==0) break;}if (ff)cout << "NO" << endl;elsecout << "YES" << endl;}
}