Page Numbering
Time limit1sMemory limit1024 MB
Count how many times each digit 0-9 appears in all odd page numbers from 1 up to N, with N as large as 10^12.
- Level
Medium7 of 10
- Topics
- Math, Implementation, Combinatorics, Bit manipulation
- Solved
- No attempts yet
Problem
A book has pages, and the publisher wants to save money by printing page numbers only on the right-hand pages, that is, the odd numbers. Write a program that counts how many times each digit is used.
Input
A single line with the integer .
Output
Print integers on one line: the number of times each digit is used. First the number of zeros, then the number of ones, and so on.