数据范围 1≤ L ≤ R ≤ 103 输出格式 输出最大的异或和 题解: 1importjava.io.*;2importjava.util.*;3importjava.text.*;4importjava.math.*;5importjava.util.regex.*;67publicclassSolution {8/*9* Complete the function below.10*/1112staticintmaxXor(intl,intr) {13intmaxx = 0;14for(inti ...
https://www.hackerrank.com/contests/w1/challenges/maximizing-xor/找了半天规律,答案竟然是暴力,伤感。我找到的方法是利用规律2^x XOR 2^x - 1会最大,感觉稍微效率高点。int maxXor(int l, int r) { i
Complete the maximizingXor function in the editor below. It must return an integer representing the maximum value calculated. maximizingXor has the following parameter(s): l: an integer, the lower bound, inclusive r: an integer, the upper bound, inclusive Input Format The first line contain...
Tony's Log HackerRank "Maximizing XOR" A natural thought is brutal-force. But as you may have already thought of, there must be a smarter one. And yes there is. Think like this: XOR gives you all different bits, if you could imagine the binary representation of L^R, it can be repre...