Source Code
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool solve() {
    int a, b, x;
    cin >> a >> b >> x;
    if (a == x || b == x) return 1;
    if (a == b) return 0;
    int mn = min(a, b);
    x -= mn;
    if (x < 0 || x % abs(a - b) != 0) return 0;
    x /= abs(a - b);
    for (; x % 2 == 0; x /= 2);
    return x == 1;
}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t;
    cin >> t;
    while (t--) {
        cout << (solve() ? "YES" : "NO") << '\n';
    }
    return 0;
}
Copy
Good Guy Jim Heartbeat
GNU G++17
9 ms
856 KB
Wrong Answer