This page is still under construction.

Parts of this page are still being built. What you see may change.

Counting Digits

Time limit1sMemory limit128 MB

Summary
For each query range [A, B], count how many times each decimal digit 0 through 9 appears in all integers written out from A to B.
Level

Medium6 of 10

Topics
Math, Implementation, Combinatorics, Brute force
Solved
No attempts yet

Problem

Write a program that counts how many times each digit from 00 to 99 appears when every integer from AA to BB (inclusive) is written down in order.

Input

The input consists of several test cases. Each test case is a single line containing two integers AA and BB separated by a space. (1≤A≤B≤1081 \le A \le B \le 10^8)

The last line of the input contains two zeros; this line is not processed.

Output

For each test case, print 1010 integers on one line, separated by spaces. The ii-th integer is the number of times the digit i−1i-1 appears when all numbers from AA to BB are written, printed in order from 00 to 99.

Examples4

  1. Example 1

    Input
    1 9
    12 321
    5987 6123
    12345678 12345679
    0 0
    
    Expected output
    0 1 1 1 1 1 1 1 1 1
    61 169 163 83 61 61 61 61 61 61
    134 58 28 24 23 36 147 24 27 47
    0 2 2 2 2 2 2 2 1 1
    
  2. Example 2

    Input
    1 1
    0 0
    
    Expected output
    0 1 0 0 0 0 0 0 0 0
    
  3. Example 3

    Input
    1 10
    0 0
    
    Expected output
    1 2 1 1 1 1 1 1 1 1
    
  4. Example 4

    Input
    10 10
    99 100
    0 0
    
    Expected output
    1 1 0 0 0 0 0 0 0 0
    2 1 0 0 0 0 0 0 0 2