The Counting Problem
Time limit1sMemory limit128 MB
For each pair (a, b), count how many times each digit 0 through 9 appears when writing every integer between them, inclusive.
- Level
Medium6 of 10
- Topics
- Math, Implementation, Brute force, Recursion
- Solved
- No attempts yet
Problem
You are given two integers and . List every integer between and , inclusive, and count how many times each digit (0 through 9) appears across the whole list.
For example, if and , the list is
1024 1025 1026 1027 1028 1029 1030 1031 1032
which contains the digit 0 ten times, the digit 1 ten times, the digit 2 seven times, the digit 3 three times, and so on.
The order of and is not fixed: may be greater than , and in that case you still count every integer between the two values.
Input
The input consists of up to 500 lines. Each line contains two integers and with . The input is terminated by a line containing 0 0, which is not part of the input.
Output
For each input line, print one line with ten integers separated by single spaces. The first integer is the number of occurrences of the digit 0, the second is the number of occurrences of the digit 1, and so on, up to the tenth integer, which is the number of occurrences of the digit 9.