CF792B.Counting-out Rhyme

普及/提高-

通过率:0%

AC君温馨提醒

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

题目描述

nn children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 11 to nn . In the beginning, the first child is considered the leader. The game is played in kk steps. In the ii -th step the leader counts out aia_{i} people in clockwise order, starting from the next person. The last one to be pointed at by the leader is eliminated, and the next player after him becomes the new leader.

For example, if there are children with numbers [8,10,13,14,16][8,10,13,14,16] currently in the circle, the leader is child 1313 and ai=12a_{i}=12 , then counting-out rhyme ends on child 1616 , who is eliminated. Child 88 becomes the leader.

You have to write a program which prints the number of the child to be eliminated on every step.

输入格式

The first line contains two integer numbers nn and kk ( 2<=n<=1002<=n<=100 , 1<=k<=n11<=k<=n-1 ).

The next line contains kk integer numbers a1,a2,...,aka_{1},a_{2},...,a_{k} ( 1<=ai<=1091<=a_{i}<=10^{9} ).

输出格式

Print kk numbers, the ii -th one corresponds to the number of child to be eliminated at the ii -th step.

输入输出样例

  • 输入#1

    7 5
    10 4 11 4 1
    

    输出#1

    4 2 5 6 1 
    
  • 输入#2

    3 2
    2 5
    

    输出#2

    3 2 
    

说明/提示

Let's consider first example:

  • In the first step child 44 is eliminated, child 55 becomes the leader.
  • In the second step child 22 is eliminated, child 33 becomes the leader.
  • In the third step child 55 is eliminated, child 66 becomes the leader.
  • In the fourth step child 66 is eliminated, child 77 becomes the leader.
  • In the final step child 11 is eliminated, child 33 becomes the leader.
首页