Time Limit: 2 sec / Memory Limit: 256 MB
配点 : 1400 点
問題文
高橋君はお母さんから数列をもらいました。この数列の長さは N で、i(1 ≦ i ≦ N) 項目の要素は i です。 高橋君は、この数列に以下の操作を合計で Q 回行いました。i 番目の操作は、パラメータ q_i であらわされ、以下のように行われます。
- いまの数列を無限回繰り返した数列の先頭 q_i 項をとって、新たな数列とする。
Q 回の操作後、この数列に 1 から N までの各々の数が何回ずつ現れるかを求めてください。
制約
- 1 ≦ N ≦ 10^5
- 0 ≦ Q ≦ 10^5
- 1 ≦ q_i ≦ 10^{18}
- 入力はすべて整数である。
入力
入力は以下の形式で標準入力から与えられる。
N Q q_1 : q_Q
出力
N 行出力せよ。i(1 ≦ i ≦ N) 行目には、Q 回の操作後の数列にあらわれる数 i の個数を表す整数ひとつを出力せよ。
入力例 1
5 3 6 4 11
出力例 1
3 3 3 2 0
1 回目の操作で、数列は 1,2,3,4,5,1 となります。
2 回目の操作で、数列は 1,2,3,4 となります。
3 回目の操作で、数列は 1,2,3,4,1,2,3,4,1,2,3 となります。 この数列には 1,2,3,4,5 がそれぞれ 3,3,3,2,0 個含まれているので、上のように出力します。
入力例 2
10 10 9 13 18 8 10 10 9 19 22 27
出力例 2
7 4 4 3 3 2 2 2 0 0
Score : 1400 points
Problem Statement
Snuke got an integer sequence from his mother, as a birthday present. The sequence has N elements, and the i-th of them is i. Snuke performs the following Q operations on this sequence. The i-th operation, described by a parameter q_i, is as follows:
- Take the first q_i elements from the sequence obtained by concatenating infinitely many copy of the current sequence, then replace the current sequence with those q_i elements.
After these Q operations, find how many times each of the integers 1 through N appears in the final sequence.
Constraints
- 1 ≦ N ≦ 10^5
- 0 ≦ Q ≦ 10^5
- 1 ≦ q_i ≦ 10^{18}
- All input values are integers.
Input
The input is given from Standard Input in the following format:
N Q q_1 : q_Q
Output
Print N lines. The i-th line (1 ≦ i ≦ N) should contain the number of times integer i appears in the final sequence after the Q operations.
Sample Input 1
5 3 6 4 11
Sample Output 1
3 3 3 2 0
After the first operation, the sequence becomes: 1,2,3,4,5,1.
After the second operation, the sequence becomes: 1,2,3,4.
After the third operation, the sequence becomes: 1,2,3,4,1,2,3,4,1,2,3.
In this sequence, integers 1,2,3,4,5 appear 3,3,3,2,0 times, respectively.
Sample Input 2
10 10 9 13 18 8 10 10 9 19 22 27
Sample Output 2
7 4 4 3 3 2 2 2 0 0