Source Code
#include <bits/stdc++.h>

using namespace std;

int main()
{
	int n;
	cin>>n;
	while (n-- >0)
	{
		int a,b,x;
		cin>>a>>b>>x;
		if (b > a)
			swap(a, b);
		if (x<a&&x!=b)
		{
			cout<<"NO"<<endl;
			continue;
		}
		else if(x==b||x==a)
		{
			cout<<"YES"<<endl;
			continue;
		}
		else
		{
			int d=a-b;
			if (d==0)
			{
				cout<<"NO"<<endl;
				continue;
			}
			while(a<x)
			{
				a+=(a-b);
				d+=d;
			}
			if (a==x)
			{
				cout<<"YES"<<endl;
				continue;
			}
			else
				cout<<"NO"<<endl;
		}
	}
    return 0;
}
Copy
Good Guy Jim Mohamedmaher
GNU G++17
270 ms
1.1 MB
Accepted