atcoder#AGC003E. [AGC003E] Sequential operations on Sequence
[AGC003E] Sequential operations on Sequence
Score : points
Problem Statement
Snuke got an integer sequence from his mother, as a birthday present. The sequence has elements, and the -th of them is . Snuke performs the following operations on this sequence. The -th operation, described by a parameter , is as follows:
- Take the first elements from the sequence obtained by concatenating infinitely many copy of the current sequence, then replace the current sequence with those elements.
After these operations, find how many times each of the integers through appears in the final sequence.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
:
Output
Print lines. The -th line should contain the number of times integer appears in the final sequence after the operations.
5 3
6
4
11
3
3
3
2
0
After the first operation, the sequence becomes: .
After the second operation, the sequence becomes: .
After the third operation, the sequence becomes: .
In this sequence, integers appear times, respectively.
10 10
9
13
18
8
10
10
9
19
22
27
7
4
4
3
3
2
2
2
0
0