Source Code
#include <iostream>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main()
{
	int t; cin >> t;
	while (t--) {
		int a, b, x;
		cin >> a >> b >> x;

		if (b > a) swap(a, b);


		int diff = abs(a - b);
		if (a == x || b == x) {
			cout << "YES" << endl;
			continue;
		}
		int tryA = x - a;
		int tryB = x - b;
		if (diff == 0) {
			cout << "NO\n";
			continue;
		}

		if (tryA % diff == 0) {
			tryA /= diff;
			tryA++;
			float ans = log2(tryA);
			if (ans - int(ans) == 0) {
				cout << "YES" << endl;
				continue;
			}
		}
		cout << "NO" << endl;
		}
	return 0;
	}








Copy
Good Guy Jim psutMoha
GNU G++17
241 ms
1.1 MB
Accepted