MKBOOK - Making Book

no tags 

A printer – who still uses moveable type – is preparing to print a set of pages for a book. These pages are to be numbered, as usual. The printer needs to know how many instances of each decimal digit will be required to set up the page numbers in the section of the book to be printed.

For example, if pages 10, 11, 12, 13, 14 and 15 are to be printed, computing the number of digits is relatively simple: just look at the page numbers that will appear, and count the number of times each digit appears. The digit 0 appears only once, the digit 1 appears 7 times, the digits 2, 3, 4 and 5 each appear once, and 6, 7, 8 and 9 don’t appear at all.

Your task in this problem is to provide the printer with the appropriate counts of the digits. You will be given the numbers of the two pages that identify the section of the book to be printed. You may safely assume that all pages in that section are to be numbered, that no leading zeroes will be printed, that page numbers are positive, and that no page will have more than three digits in its page number.

Input

There will be multiple cases to consider. The input for each case has two integers, A and B, each of which is guaranteed to be positive. These identify the pages to be printed. That is, each integer P between A and B, including A and B, is to be printed. A single zero will follow the input for the last case.

Output

For each input case, display the case number (1, 2, …) and the number of occurrences of each decimal digit 0 through 9 in the specified range of page numbers. Display your results in the format shown in the examples below.

Example

Input:
10 15
912 912
900 999
0

Output:
Case 1: 0:1 1:7 2:1 3:1 4:1 5:1 6:0 7:0 8:0 9:0
Case 2: 0:0 1:1 2:1 3:0 4:0 5:0 6:0 7:0 8:0 9:1
Case 3: 0:20 1:20 2:20 3:20 4:20 5:20 6:20 7:20 8:20 9:120

hide comments
mukul: 2010-10-01 16:31:40

@ 104
THANKS

Knight: 2010-07-09 04:41:50

check the test case with A greater than B coz A can be greater than B also

subramanian: 2010-06-01 17:29:46

its coming as WA though it works perfectly in ma system!!!!

Maciej Grzymkowski: 2009-12-14 23:43:41

- disregard it, please -

Last edit: 2010-04-27 15:07:25
Aragon: 2009-12-11 06:22:03

Is anyone here solving this problem now?? I have correct code. But judge says its wrong. can u help me out?

Bittu Sarkar: 2009-09-12 23:05:04

Because you solved a tutorial problem not a classical one

mostafa hany: 2009-07-15 16:59:09

i got this Accepted but its removed from my submissions, why???

~!(*(@*!@^&: 2009-03-17 00:33:23

MDIGIT


Added by:Camilo Andrés Varela León
Date:2007-10-07
Time limit:0.200s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:North Central North America Regional Programming Contest - 2003