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;
}
目录
相关文章
German Collegiate Programming Contest 2019 B . Bouldering (最短路)
German Collegiate Programming Contest 2019 B . Bouldering (最短路)
101 0
German Collegiate Programming Contest 2019 B . Bouldering (最短路)
AtCoder Beginner Contest 226 E - Just one(dfs求连通块 组合数学)
AtCoder Beginner Contest 226 E - Just one(dfs求连通块 组合数学)
105 0
AtCoder Beginner Contest 221 E - LEQ(组合数学 树状数组)
AtCoder Beginner Contest 221 E - LEQ(组合数学 树状数组)
153 0
|
机器学习/深度学习 人工智能 Java
AtCoder Beginner Contest 215 D - Coprime 2 (质因子分解 gcd)
AtCoder Beginner Contest 215 D - Coprime 2 (质因子分解 gcd)
108 0
|
算法
AtCoder Beginner Contest 213 E - Stronger Takahashi(01BFS)
AtCoder Beginner Contest 213 E - Stronger Takahashi(01BFS)
135 0
|
机器学习/深度学习
AtCoder Beginner Contest 215 E - Chain Contestant (状压dp)
AtCoder Beginner Contest 215 E - Chain Contestant (状压dp)
120 0
AtCoder Beginner Contest 203(Sponsored by Panasonic) D.Pond(二分+二维前缀和)
AtCoder Beginner Contest 203(Sponsored by Panasonic) D.Pond(二分+二维前缀和)
90 0
P4137 Rmq Problem / mex(主席树)
P4137 Rmq Problem / mex(主席树)
84 0
|
人工智能
Nordic Collegiate Programming Contest 2020 D.Damsindistress (dp)
Nordic Collegiate Programming Contest 2020 D.Damsindistress (dp)
94 0
AtCoder Beginner Contest 176 D - Wizard in Maze(01BFS)
AtCoder Beginner Contest 176 D - Wizard in Maze(01BFS)
115 0