https://xwmm.github.io/2019/05/23/%E4%BD%8D%E8%BF%90%E7%AE%97/
数学函数很重要 gcd,求和,ect。
/*
1:
Problem Description
Bit operation is a common computing method in computer science ,Now we have two positive integers A and B ,Please find a positive integer C that minimize the value of the formula (A xor C) & (B xor C) .Sometimes we can find a lot of C to do this ,So you need to find the smallest C that meets the criteria .
For example ,Let's say A is equal to 5 and B is equal to 3 ,we can choose C=1,3.... ,so the answer we're looking for C is equal to 1.
Input
The input file contains T test samples.(1<=T<=100)
The first line of input file is an integer T.
Then the T lines contains 2 positive integers, A and B, (1≤A,B<232)
Output
For each test case,you should output the answer and a line for each answer.
Sample Input
1
3 5
Sample Output
1*/
#include <iostream>
using namespace std;
int main(){
int n,i,i0;
unsigned long a,b,c=0,d;
cin>>n;
for(i=0;i<n;i++){
cin>>a>>b;
d=1;
d<<=31;
for(i0=31;i0>=0;i0--){
c<<=1;
if(((a|d)==a)&&((b|d)==b)){
c|=0x01;
}
d>>=1;
}
if(c==0) cout<<1;
else cout<<c;
cout<<'\n';
}
}
/*
原式 (a^c)&(b^c)
a=1,b=1时 c=0,原式=1 c=1,原式=0
a=1,b=0 或 a=0,b=1时 c=1 或 c=0 原式=0
a=0,b=0时 c=1,原式=1 c=0,原式=0
所以想要c尽可能小就要在a=1,b=1以外的情况让c=0
只需依次运算每一位即可
*/