Source Code

# include <iostream>
# include <math.h>
using namespace std;
int main(){
    int n;
    cin>>n;
   
    for (int i=0;i<n;i++){
       int a,b,x;
       cin>>a>>b>>x;
       bool flag = false;
    if (a==x || b==x){cout <<"YES"<<endl; continue;}
       while (a<x){
           a = a + abs(a-b);
           if (a==x){
               flag = true;
                cout<<"YES"<<endl;
           }
        }
        // bool
        while (b<x && flag==false){
           b = b + abs(a-b);
           if (b==x){
               flag = true;
                cout<<"YES"<<endl;
           }
        }
        if (!flag) cout<<"NO";
    }
    return 0;
}
Copy
Good Guy Jim yaman
GNU G++17
2 ms
252 KB
Wrong Answer