Codeforces Round 421 (Div. 1)
D
Mister B and Astronomers
Codeforces
2900
原题
← CE →
翻译中…

After studying the beacons Mister B decided to visit alien's planet, because he learned that they live in a system of flickering star Moon. Moreover, Mister B learned that the star shines once in exactly $*T*$ seconds. The problem is that the star is yet to be discovered by scientists.

翻译中…

There are $*n*$ astronomers numerated from $1$ to $*n*$ trying to detect the star. They try to detect the star by sending requests to record the sky for $1$ second.

翻译中…

The astronomers send requests in cycle: the $*i*$-th astronomer sends a request exactly $*a*_{*i*}$ second after the $(*i* - 1)$-th (i.e. if the previous request was sent at moment $*t*$, then the next request is sent at moment $*t* + *a*_{*i*}$); the $1$-st astronomer sends requests $*a*_{1}$ seconds later than the $*n*$-th. The first astronomer sends his first request at moment $0$.

翻译中…

Mister B doesn't know the first moment the star is going to shine, but it's obvious that all moments at which the star will shine are determined by the time of its shine moment in the interval $[0, *T*)$. Moreover, this interval can be split into $*T*$ parts of $1$ second length each of form $[*t*, *t* + 1)$, where $*t* = 0, 1, 2, ..., (*T* - 1)$.

翻译中…

Mister B wants to know how lucky each astronomer can be in discovering the star first.

翻译中…

For each astronomer compute how many segments of form $[*t*, *t* + 1)$ ($*t* = 0, 1, 2, ..., (*T* - 1)$) there are in the interval $[0, *T*)$ so that this astronomer is the first to discover the star if the first shine of the star happens in this time interval.

翻译中…

Input

翻译中…

The first line contains two integers $*T*$ and $*n*$ ($1 ≤ *T* ≤ 10^{9}$, $2 ≤ *n* ≤ 2·10^{5}$).

翻译中…

The second line contains $*n*$ integers $*a*_{1}, *a*_{2}, ..., *a*_{*n*}$ ($1 ≤ *a*_{*i*} ≤ 10^{9}$).

翻译中…

Output

翻译中…

Print $*n*$ integers: for each astronomer print the number of time segments describer earlier.

翻译中…

Note

翻译中…

In the first sample test the first astronomer will send requests at moments $*t*_{1} = 0, 5, 10, ...$, the second — at moments $*t*_{2} = 3, 8, 13, ...$. That's why interval $[0, 1)$ the first astronomer will discover first at moment $*t*_{1} = 0$, $[1, 2)$ — the first astronomer at moment $*t*_{1} = 5$, $[2, 3)$ — the first astronomer at moment $*t*_{1} = 10$, and $[3, 4)$ — the second astronomer at moment $*t*_{2} = 3$.

翻译中…

In the second sample test interval $[0, 1)$ — the first astronomer will discover first, $[1, 2)$ — the second astronomer, $[2, 3)$ — the third astronomer, $[3, 4)$ — the fourth astronomer, $[4, 5)$ — the first astronomer.

翻译中…

样例

Input #1
4 2
2 3
Output #1
3 1
InputCopy OutputCopy
Input #2
5 4
1 1 1 1
Output #2
2 1 1 1
InputCopy OutputCopy
题目信息
题号
819D
时间限制
2 s
内存限制
256 MB
标签
数论

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。