33OJ
登录 注册

#P14074. [GESP202509 五级] 有趣的数字和

[GESP202509 五级] 有趣的数字和

Background

Corresponding multiple-choice and true/false questions: https://ti.luogu.com.cn/problemset/1193

To ensure that only algorithms with a reasonable time complexity can pass this problem, the time limit has been lowered.

Problem Description

If the binary representation of a positive integer contains an odd number of 11s, Little A considers this positive integer interesting.

For example, the binary representation of 77 is (111)2(111)_2, which contains 33 ones, so 77 is interesting. However, 9=(1001)29=(1001)_2 contains 22 ones, so 99 is not interesting.

Given positive integers l,rl,r, please count the sum of all interesting integers nn satisfying l≤n≤rl\le n\le r.

Input Format

One line with two positive integers l,rl,r, the given positive integers.

Output Format

One line with one positive integer, the sum of the interesting integers between ll and rr.

3 8
19
65 36248
328505490

Hint

Constraints

For 40%40\% of the test cases, 1≤l≤r≤1041\le l\le r\le 10^4.

For another 30%30\% of the test cases, l=1l=1 and r=2k−1r=2^k-1, where kk is a positive integer greater than 11.

For all test cases, 1≤l≤r≤1091 \le l\le r\le 10^9.

Note

Because the constraints of this problem are large, use the long long integer type.

Translated by QwenWork