Counting Digits
Time limit1sMemory limit128 MB
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 to appears when every integer from to (inclusive) is written down in order.
Input
The input consists of several test cases. Each test case is a single line containing two integers and separated by a space. ()
The last line of the input contains two zeros; this line is not processed.
Output
For each test case, print integers on one line, separated by spaces. The -th integer is the number of times the digit appears when all numbers from to are written, printed in order from to .