题解 | #或与异或#
或与异或
https://ac.nowcoder.com/acm/problem/235688
只需要判断目标数字是否由 “0 1”、“1 0” 和 “1 1” 这三种位置的集合组成即可。
证明(图片中给出证明,此处无法读取请点击:https://blog.nowcoder.net/n/2841f568ef4a478f84d3368ace8d4bd8):
代码:
#include <bits/stdc++.h> using namespace std; #define ll long long int main() { int ttx; cin >> ttx; while(ttx --) { ll a, b, c; cin >> a >> b >> c; ll x, y, z; x = a & b, y = (~a) & b, z = a & (~b); if(!(x & (~c))) c &= ~x; if(!(y & (~c))) c &= ~y; if(!(z & (~c))) c &= ~z; if(c) cout << "NO" << endl; else cout << "YES" << endl; } return 0; }