CF819D.Mister B and Astronomers

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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 TT seconds. The problem is that the star is yet to be discovered by scientists.

There are nn astronomers numerated from 11 to nn trying to detect the star. They try to detect the star by sending requests to record the sky for 11 second.

The astronomers send requests in cycle: the ii -th astronomer sends a request exactly aia_{i} second after the (i1)(i-1) -th (i.e. if the previous request was sent at moment tt , then the next request is sent at moment t+ait+a_{i} ); the 11 -st astronomer sends requests a1a_{1} seconds later than the nn -th. The first astronomer sends his first request at moment 00 .

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)[0,T) . Moreover, this interval can be split into TT parts of 11 second length each of form [t,t+1)[t,t+1) , where t=0,1,2,...,(T1)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,t+1) ( t=0,1,2,...,(T1)t=0,1,2,...,(T-1) ) there are in the interval [0,T)[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.

输入格式

The first line contains two integers TT and nn ( 1<=T<=1091<=T<=10^{9} , 2<=n<=21052<=n<=2·10^{5} ).

The second line contains nn integers a1,a2,...,ana_{1},a_{2},...,a_{n} ( 1<=ai<=1091<=a_{i}<=10^{9} ).

输出格式

Print nn integers: for each astronomer print the number of time segments describer earlier.

输入输出样例

  • 输入#1

    4 2
    2 3
    

    输出#1

    3 1 
    
  • 输入#2

    5 4
    1 1 1 1
    

    输出#2

    2 1 1 1 
    

说明/提示

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

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

首页