MZVRK - Whirligig number

By removing all digits left of the rightmost digit one in the binary representation of some integer, we get what is called the "whirligig" of that number. For example, the whirligig of 6 i.e. (110)2 is 2 i.e. (10)2, and the whirligigof 40 i.e. (101000)2 is 8 i.e. (1000)2. Write a program that will calculate the sum of the whirligig of all numbers between two given numbers A and B (inclusive).

Input

First and only line of input contains two integers A and B, 1 ≤ A ≤ B ≤ 10^15.

Output

First and only line of output should contain the sum from the problem statement.

Note: the result will fit into the 64-bit signed integer type.

Sample

input
176 177

output 
17

input
5 9

output
13

input
25 28

output
8

Được gửi lên bởi:psetter
Ngày:2009-02-28
Thời gian chạy:1s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET
Nguồn bài:COI 05

hide comments
2017-10-08 04:00:38
{dinh truong lam}

ez game ^^
2017-02-05 17:19:21
đùa à for mask chạy từ đầu đến cuối cập nhật kết quả cái là accept =")) time bữa nay chặt ghê ="))
2016-10-26 16:17:27
có lẽ không cần đệ quy có nhớ !
2015-11-05 07:26:30 Prismatic
time nên giới hạn 0.01s :))
2015-05-24 07:06:36 Duc M. Pham
Đpt chuẩn O(logA+logB)!
2013-10-31 16:15:19 Chuyên Triết Tổng Hợp
clq nhưng hôm nay là halloween
2013-09-15 11:24:22 Hồ Sỹ Thành
chắc không phải chứ? i.e. nghĩa là in other words, tức là "nói cách khác" chứ?
2013-03-15 15:40:48 a;slkfjasl;fkj
đúng rồi i.e nghĩa là: nghĩa là
Ko đùa đâu =))
2013-01-19 05:25:51 Danh Nguyen
i.e. i.e. "nghia la"
2013-01-06 16:37:17 a;slkfjasl;fkj
bài này rắc rối ghê :(
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.