#P6218. [USACO06NOV] Round Numbers S

[USACO06NOV] Round Numbers S

Problem Description

If the binary representation of a positive integer contains at least as many 00's as 11's, then it is called a "round number".

For example, the binary representation of 99 is 10011001, which has 22 zeros and 22 ones. Therefore, 99 is a "round number".

Please calculate how many "round numbers" are in the interval [l,r][l, r].

Input Format

One line containing two integers l,rl, r.

Output Format

One line containing one integer, the number of "round numbers" in the interval [l,r][l, r].

2 12
6

Hint

Constraints

For 100%100\% of the testdata, 1l,r2×1091 \le l, r \le 2 \times 10^9.


Sample Explanation

There are 66 "round numbers" in the interval [2,12][2, 12]: 2,4,8,9,10,122, 4, 8, 9, 10, 12.

Translated by ChatGPT 5