MZVRK - Whirligig number
English | Vietnamese |
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 whirligig of 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 ≤ 1015.
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
Added by: | psetter |
Date: | 2009-02-28 |
Time limit: | 1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ERL JS-RHINO NODEJS PERL6 VB.NET |
Resource: | COI 05 |