Source Code
#include <iostream>
using namespace std;
int main()
{
	int t;
	cin >> t;

	for (int i = 0; i < t; i++) {
		int flagA = 0;
		int flagB = 0;
		int a;
		int b;
		int x;
		cin >> a >> b >> x;
		
		while (true) {
			if (a == x) {

				flagA = 1;
				break;
			}


			else	if (a > x || a == a + abs(a - b)) {
				flagA = 0;
				break;
			}
			a = a + abs(a - b);
		}

		while (true) {
			if (b == x) {
				flagB = 1;
				break;
			}

			else if (b > x || b == b + abs(a - b)) {
				flagB = 0;
				break;
			}
			b = b + abs(a - b);
		}
		if (flagA == 1 || flagB == 1) cout << "YES" << endl;
		else if (flagA == 0 && flagB == 0) cout << "NO" << endl;

	}
}
Copy
Good Guy Jim microwave6
GNU G++17
194 ms
844 KB
Wrong Answer