101213: [AtCoder]ABC121 D - XOR World

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $400$ points

Problem Statement

Let $f(A, B)$ be the exclusive OR of $A, A+1, ..., B$. Find $f(A, B)$.

What is exclusive OR?

The bitwise exclusive OR of integers $c_1, c_2, ..., c_n$ (let us call it $y$) is defined as follows:

  • When $y$ is written in base two, the digit in the $2^k$'s place ($k \geq 0$) is $1$ if, the number of integers among $c_1, c_2, ...c_m$ whose binary representations have $1$ in the $2^k$'s place, is odd, and $0$ if that count is even.

For example, the exclusive OR of $3$ and $5$ is $6$. (When written in base two: the exclusive OR of 011 and 101 is 110.)

Constraints

  • All values in input are integers.
  • $0 \leq A \leq B \leq 10^{12}$

Input

Input is given from Standard Input in the following format:

$A$ $B$

Output

Compute $f(A, B)$ and print it.


Sample Input 1

2 4

Sample Output 1

5

$2, 3, 4$ are 010, 011, 100 in base two, respectively. The exclusive OR of these is 101, which is $5$ in base ten.


Sample Input 2

123 456

Sample Output 2

435

Sample Input 3

123456789012 123456789012

Sample Output 3

123456789012

Input

题意翻译

### 题目描述 令 $f(A, B)$ 为 $A,\,A+1,\,\dots,\,B$ 的异或和。求 $f(A, B)$。 什么是异或和? $c_1,\,c_2,\,\dots,\,c_n$ 的异或和(记做 $y$)的定义如下: * **二进制下**,若 $c_1,\,c_2,\,\dots,\,c_n$ 中有奇数个数字满足第 $k$ 位为 $1$,则 $y$ 的第 $k$ 位为 $1$;若偶数个数字满足,则 $y$ 的第 $k$ 位为 $0$。 比如,$3$ 和 $5$ 的异或和为 $6$。(二进制下,`011` 和 `101` 的异或和为 `110`) ### 样例说明 二进制下,$2,\,3,\,4$ 分别是 `010`,`011`,`100`。异或和是 `101`,十进制下是 $5$。

加入题单

算法标签: