P27075 [AtCoder] Count Dividing XOR
提高-
题目描述

Problem Description

Given integers \( L \) and \( R \), count the number of pairs of integers \( (A, B) \) that satisfy the following conditions:

  • \( L \leq A < B \leq R \)
  • \( A \) is divisible by \( A \oplus B \)
  • \( B \) is divisible by \( A \oplus B \)

Here, \( \oplus \) denotes the bitwise XOR operation.

The bitwise XOR operation for non-negative integers \( A \) and \( B \), denoted \( A \oplus B \), is defined as follows:

  • When \( A \oplus B \) is written in binary, the digit in the \( 2^k \) (where \( k \geq 0 \)) place is 1 if exactly one of the digits in the \( 2^k \) place of \( A \) and \( B \) in binary is 1, otherwise it is 0.

For example, \( 3 \oplus 5 = 6 \) (in binary: \( 011 \oplus 101 = 110 \)).

In general, the bitwise XOR of \( k \) non-negative integers \( p_1, p_2, p_3, \dots, p_k \) is defined as \( (\dots ((p_1 \oplus p_2) \oplus p_3) \oplus \dots \oplus p_k) \), and it can be proven that this does not depend on the order of \( p_1, p_2, p_3, \dots, p_k \).

Input Format

The input is given from the standard input in the following format:

\( L \) \( R \)

Output Format

Output the answer.

Sample Input and Output

Sample Input #1

3 6

Sample Output #1

2

Sample Input #2

1 100

Sample Output #2

124

Sample Input #3

999000000 1000000000

Sample Output #3

1726239

Notes/Hints

Constraints

  • \( 1 \leq L < R \leq 10^{18} \)
  • \( R - L \leq 10^6 \)
  • All values given in the input are integers

Sample Explanation 1

The pairs \( (A, B) = (4, 5) \) and \( (A, B) = (4, 6) \) satisfy the conditions.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 6
样例输出
2