304298: CF819D. Mister B and Astronomers
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Mister B and Astronomers
题意翻译
外星球每隔T秒中只有一秒可以被观测到,其它T-1秒无法被观测。n个天文学家(分别编号为1,...,n)轮流观测天空1秒,且第i+1个科学家在第i个天文学家后ai+1秒后才执行观测,而第一个天文学家则在第n个天文学家后a1秒后才执行观测,且第一个天文学家在0秒时执行第一次观测(即第一个天文学家观测的时间是[0,1),第二个科学家在[a2,a2+1)时观测,而最后一个天文学家在[a2+a3+...+an-1,a2+a3+...+an-1+1)时观测,之后再过a1秒后第一个天文学家继续观测)。 由于外星球具体在首次观测之后的T秒中的哪一秒出现是不确定的,若外星球在[i, i+1)时出现(0<=i<T-1),且天文学家j是首个观测到星球的人,则称j抢占了[i,i+1)时间片段。也就是说,如果把所有的观测时间模T之后,最先观测到时间片段[i,i+1)将占有这个时间片段。 问每个天文学家所占有的时间片段各是多少。 T <= 1e9, n <= 2e5, ai <= 1e9 例如, T = 4,n = 2, a1 = 2, a2 = 3 第一个天文学家观测的时间点是t=0,5,10,……,第二个天文学家是t=3,8,13,…… 第一个天文学家在 t=0 时占有 [0,1), 在 t=5 时占有[1,2), 在 t=10 时占有[2,3) 第二个天文学家在 t=3 时占有 [3,4)题目描述
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.输入输出格式
输入格式
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} $ ).
输出格式
Print $ n $ 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