Source Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool solve() {
    ll a, b, x;
    cin >> a >> b >> x;
    if (a == x || b == x) return 1;
    if (a == b) return 0;
    if (a < b) swap(a, b);
    for (; a < x; a += (a - b));
    return a == x; 
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    int t;
    cin >> t;
    while (t--) {
        cout << (solve() ? "YES" : "NO") << '\n';
    }
    return 0;
}
Copy
Good Guy Jim Heartbeat
GNU G++17
26 ms
1.1 MB
Accepted