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
rrishabhj: 2016-01-21 15:12:20

a can be greater that b.....cost me 1 wa!

Vicky: 2015-04-17 10:37:09

yes a>b ;:D

Bhrigu Srivastava: 2014-07-30 09:29:53

it will show you WA if u do not consider a>b

reggaeguitar: 2013-03-01 15:49:23

@cannot If you use Java you can test code by making JUnit test cases

cannot_in2_coding: 2011-12-22 13:57:09

Can someone give me advice on testing code?Not just for this problem in general.

Vladimir Kirichenkoff: 2011-07-17 23:39:02

Knight is right. A can be greater than B.

Travis T: 2011-02-25 01:22:36

I also need help with the same code

tupapa hipolito: 2011-02-11 21:23:27

Miren Valsa de mmg .. arreglen esa mierda!! ..

Ahmed Atif Salah: 2011-02-07 17:42:47

I hate the word Wrong-Answer

sayed khalaf sayed: 2011-02-07 00:06:33

I have correct code. But judge says its wrong answer. can u help me out?


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