TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

To write binary numbers we need only two digits ‘0’ and ‘1’. To write a specific value we need a fixed number of ones, but of course number of zeroes may vary because of leading zeroes. For example to write values between 5 and 10 (inclusive) we need total 12 ones as shown in the figure on the left. You have to write a program that finds total number of ones that are required to write numbers in binary within a given range a and b.

Input Format

The input file can contain many lines of inputs. Each line contains two positive integers a and b (0 < a ≤ b ≤ 2000000000).


Input is terminated by a line containing two zeroes. This line should not be processed.

Output Format

For each line of input of input produce one line of output. This line contains the serial of output followed by an integer which denotes the number of ‘1’ s required to write all the values between a and b (inclusive) in binary. Look at the output for sample input for details.

Sample Input 1

5 10
20 30
0 0

Sample Output 1

Case 1: 12
Case 2: 35

Hints

Problem Source

Migrated from old NTUJ.

icpc regional 2009, dhaka site

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 5000 65536 131072