Codeforces 1554C - Mikasa MEX
input
5
3 5
4 6
3 2
69 696
123456 654321
output
4
3
0
640
530866
给出n,m从n ^ 0 -> n ^ m中最小为出现的非负整数
int main() {
int _ = read;
while (_--) {
int n = read, m = read;
if(n > m) {
puts("0");
continue;
}
++m;
int ans = 0;
for (int i = 30; i >= 0; i--) {
if ((m & (1 << i)) && !(n & (1 << i))) ans |= 1 << i;
else if ((n & (1 << i)) && !(m & (1 << i))) break;
}
printf("%d\n", ans);
}
return 0;
}