How Many Zeros?
Time limit1sMemory limit128 MB
For each range n to m, count how many times the digit 0 appears when every integer in the range is written in decimal without leading zeros.
- Level
Medium7 of 10
- Topics
- Math, Implementation, Number theory, Brute force
- Solved
- No attempts yet
Problem
Write a program that, when every integer from to is written down one by one on paper, counts how many times the digit is written. Each number is written in decimal with no leading zeros. For example, writing writes the digit once, and the number is written as "", which is one zero.
Input
The input consists of several test cases. Each test case is a single line containing two integers and separated by a space, with . On the last line is negative; do not process that line and terminate the program.
Output
For each test case, print on its own line the total number of times the digit is written when listing the numbers from to .