#B3708. Counting Summoned Spirits by Remainder
Counting Summoned Spirits by Remainder
Counting Summoned Spirits by Remainder
The Divine Tree Master has summoned $9 \times 10^{n-1}$ domesticated little spirits, each assigned a unique n-digit identification number. The IDs are sequential, ranging from $10^{n-1}$ to $10^n - 1$ (i.e. from 1 followed by n-1 zeroes to n digits of 9). For example, for n = 1 the IDs are 1 to 9, and for n = 3 the IDs are 100 to 999.
The Divine Tree Master plans to divide these little spirits into k groups. The spirits are grouped based on the remainder when their ID is divided by k. Specifically, the spirits whose ID gives a remainder of p-1 are assigned to group p (with p from 1 to k). For instance, if an ID is 101 and k = 4, then 101 mod 4 = 1, so the spirit is placed into group 2.
Your task is to determine, for each group, how many spirits belong to that group.
Note: All formulas must be written in LaTeX format.
inputFormat
The input consists of a single line containing two integers (n) and (k) ((1 \le n \le 18), (1 \le k \le 10^5)). Here, (n) denotes the number of digits of the spirit IDs and (k) is the number of groups.
outputFormat
Output a single line containing (k) integers. The (i)-th integer represents the number of spirit IDs that produce a remainder of (i-1) when divided by (k). The numbers should be separated by a single space.
sample
1 2
4 5