3706.Little Girl and Maximum XOR

Time Limit: 1s Memory Limit: 256MB

A little girl loves problems on bitwise operations very much. Here's one of them.You are given two integers l and r. Let's consider the values of 3706_1.png for all pairs of integers a and b (l \le a \le b \le r). Your task is to find the maximum value among all considered ones.Expression 3706_2.png means applying bitwise excluding or operation to integers x and y. The given operation exists in all modern programming languages, for example, in languages C++ and Java it is represented as "^", in Pascal - as «xor».

Input Format(From the terminal/stdin)

Input The single line contains space-separated integers l and r (1 \le l \le r \le 1018).Please, do not use the %lld specifier to read or write 64-bit integers in C++. It is preferred to use the cin, cout streams or the %I64d specifier.

Output Format(To the terminal/stdout)

Output In a single line print a single integer - the maximum value of 3706_1.png for all pairs of integers a, b (l \le a \le b \le r).

Sample Input 1

Copy
1 2
 · \n

Sample Output 1

Copy
3
 \n

Sample Input 2

Copy
8 16
 ·  \n

Sample Output 2

Copy
31
  \n

Sample Input 3

Copy
1 1
 · \n

Sample Output 3

Copy
0
 \n

Submit

请先 登录

© 2025 FAQs