牛客竞赛题目讲解_或与异或
2022-05-03 14:48 作者:Clayton_Zhou | 我要投稿
// https://ac.nowcoder.com/acm/contest/11225/E
#include<bits/stdc++.h>
using namespace std;
#define LL long long
LL a,b,tar;
set<pair<LL,LL>> st;
bool dfs(LL x,LL y){
if(x==tar||y==tar)return 1;
if(x<y)swap(x,y);
if(st.count({x,y}))return 0;
st.insert({x,y});
if(dfs(x|y,x)||dfs(x|y,y)||dfs(x&y,x)||dfs(x&y,y)
||dfs(x^y,x)||dfs(x^y,y))return 1;
return 0;
}
int main(){
int T;cin>>T;
while(T--){
cin>>a>>b>>tar;
st.clear();
if(dfs(a,b))cout<<"YES\n";
else cout<<"NO\n";
}
}