Codeforces 1554C - Mikasa MEX

简介: inputoutput给出n,m从n ^ 0 -> n ^ m中最小为出现的非负整数

f5b09e2061cf44bf85200366cc76159e.png

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;
}
目录
相关文章
|
4月前
Knight Moves(POJ2243)
Knight Moves(POJ2243)
AtCoder Beginner Contest 226 E - Just one(dfs求连通块 组合数学)
AtCoder Beginner Contest 226 E - Just one(dfs求连通块 组合数学)
99 0
P4137 Rmq Problem / mex(主席树)
P4137 Rmq Problem / mex(主席树)
77 0
AtCoder Beginner Contest 221 E - LEQ(组合数学 树状数组)
AtCoder Beginner Contest 221 E - LEQ(组合数学 树状数组)
148 0
POJ-2488,A Knight's Journey(DFS)
POJ-2488,A Knight's Journey(DFS)
|
机器学习/深度学习 人工智能 BI
codeforces-1242-B 0-1 MST
B. 0-1 MST time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Ujan has a lot of useless stuff in his drawers, a considerable part of which are his math notebooks: it is time to sort them out.
160 0
codeforces-1242-B 0-1 MST
LeetCode之Island Perimeter
LeetCode之Island Perimeter
122 0
LeetCode之Island Perimeter
HDOJ/HDU 1372 Knight Moves(经典BFS)
HDOJ/HDU 1372 Knight Moves(经典BFS)
124 0
HDOJ/HDU 1241 Oil Deposits(经典DFS)
HDOJ/HDU 1241 Oil Deposits(经典DFS)
83 0