Given two integers:LAndR
Limit L ≤ A ≤ B ≤ r, find outAXORB.
Input Format
The first line containsLThe first line containsR
Data range
1 ≤ L ≤ r ≤103
Output Format
Maximum exclusive or sum of outputs
Question:
1 import java.io.*; 2 import java.util.*; 3 import java.text.*; 4 import java.math.*; 5 import java.util.regex.*; 6 7 public class Solution { 8 /* 9 * Complete the function below.10 */11 12 static int maxXor(int l, int r) {13 int maxx = 0;14 for(int i = l;i <= r;i++){15 for(int j = l;j <= r;j++){16 if(i != j)17 maxx = Math.max(maxx,i^j);18 }19 }20 return maxx;21 22 }23 24 public static void main(String[] args) {25 Scanner in = new Scanner(System.in);26 int res;27 int _l;28 _l = Integer.parseInt(in.nextLine());29 30 int _r;31 _r = Integer.parseInt(in.nextLine());32 33 res = maxXor(_l, _r);34 System.out.println(res);35 36 }37 }