luogu#P1554. [USACO06DEC] 梦中的统计 Dream Counting B

[USACO06DEC] 梦中的统计 Dream Counting B

Background

Bessie is half asleep. After a while, she realizes she is counting and cannot fall asleep.

Problem Description

Bessie's mind is sharp, as if she vividly sees each number she has counted. She starts to pay attention to every digit (090 \ldots 9): how many times does each digit appear during the counting process?

Given two integers MM and NN, determine how many times each digit appears in the sequence [M,M+1,M+2,,N1,N][M, M + 1, M + 2, \ldots, N - 1, N].

Input Format

Line 11: Two integers MM and NN separated by a space.

Output Format

Line 11: Ten integers separated by spaces, representing how many times the digits 090 \ldots 9 appear in the sequence.

129 137
1 10 2 9 1 1 1 1 0 1

Hint

Constraints: 1MN2×1091 \leq M \leq N \leq 2 \times 10^9, 0NM5×1050 \leq N - M \leq 5 \times 10^5.

Translated by ChatGPT 5