{"problem":{"name":"B. Counting-out Rhyme","description":{"content":"_n_ children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to _n_. In the beginning, the first child is considered the leader. The game is played i","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF792B"},"statements":[{"statement_type":"Markdown","content":"_n_ children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to _n_. In the beginning, the first child is considered the leader. The game is played in _k_ steps. In the _i_\\-th step the leader counts out _a__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.\n\nFor example, if there are children with numbers \\[8, 10, 13, 14, 16\\] currently in the circle, the leader is child 13 and _a__i_ = 12, then counting-out rhyme ends on child 16, who is eliminated. Child 8 becomes the leader.\n\nYou have to write a program which prints the number of the child to be eliminated on every step.\n\n## Input\n\nThe first line contains two integer numbers _n_ and _k_ (2 ≤ _n_ ≤ 100, 1 ≤ _k_ ≤ _n_ - 1).\n\nThe next line contains _k_ integer numbers _a_1, _a_2, ..., _a__k_ (1 ≤ _a__i_ ≤ 109).\n\n## Output\n\nPrint _k_ numbers, the _i_\\-th one corresponds to the number of child to be eliminated at the _i_\\-th step.\n\n[samples]\n\n## Note\n\nLet's consider first example:\n\n*   In the first step child 4 is eliminated, child 5 becomes the leader.\n*   In the second step child 2 is eliminated, child 3 becomes the leader.\n*   In the third step child 5 is eliminated, child 6 becomes the leader.\n*   In the fourth step child 6 is eliminated, child 7 becomes the leader.\n*   In the final step child 1 is eliminated, child 3 becomes the leader.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"[{\"iden\":\"statement\",\"content\":\"#cf_span[n] 个孩子站成一个圆圈玩数数淘汰游戏。孩子们按顺时针方向编号为 #cf_span[1] 到 #cf_span[n]。游戏开始时，第一个孩子被视为领导者。游戏进行 #cf_span[k] 步。在第 #cf_span[i] 步中，领导者从下一个人开始顺时针数出 #cf_span[ai] 个人。被领导者指向的最后一个人被淘汰，其后一个人成为新的领导者。\\n\\n例如，如果当前圆圈中的孩子编号为 #cf_span[[8, 10, 13, 14, 16]]，领导者是孩子 #cf_span[13]，且 #cf_span[ai = 12]，则数数结束于孩子 #cf_span[16]，他被淘汰。孩子 #cf_span[8] 成为新的领导者。\\n\\n你需要编写一个程序，在每一步输出被淘汰孩子的编号。\\n\\n第一行包含两个整数 #cf_span[n] 和 #cf_span[k]（#cf_span[2 ≤ n ≤ 100]，#cf_span[1 ≤ k ≤ n - 1]）。\\n\\n下一行包含 #cf_span[k] 个整数 #cf_span[a1, a2, ..., ak]（#cf_span[1 ≤ ai ≤ 109]）。\\n\\n请输出 #cf_span[k] 个数字，第 #cf_span[i] 个数字对应第 #cf_span[i] 步被淘汰的孩子编号。\"}},{\"iden\":\"input\",\"content\":\"第一行包含两个整数 #cf_span[n] 和 #cf_span[k]（#cf_span[2 ≤ n ≤ 100]，#cf_span[1 ≤ k ≤ n - 1]）。下一行包含 #cf_span[k] 个整数 #cf_span[a1, a2, ..., ak]（#cf_span[1 ≤ ai ≤ 109]）。\"},{\"iden\":\"output\",\"content\":\"请输出 #cf_span[k] 个数字，第 #cf_span[i] 个数字对应第 #cf_span[i] 步被淘汰的孩子编号。\"},{\"iden\":\"examples\",\"content\":\"输入\\n7 5\\n10 4 11 4 1\\n输出\\n4 2 5 6 1 \\n\\n输入\\n3 2\\n2 5\\n输出\\n3 2 \"},{\"iden\":\"note\",\"content\":\"考虑第一个例子：\\n在第一步，孩子 #cf_span[4] 被淘汰，孩子 #cf_span[5] 成为领导者。\\n在第二步，孩子 #cf_span[2] 被淘汰，孩子 #cf_span[3] 成为领导者。\\n在第三步，孩子 #cf_span[5] 被淘汰，孩子 #cf_span[6] 成为领导者。\\n在第四步，孩子 #cf_span[6] 被淘汰，孩子 #cf_span[7] 成为领导者。\\n在最后一步，孩子 #cf_span[1] 被淘汰，孩子 #cf_span[3] 成为领导者。\"}]","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ n, k \\in \\mathbb{Z} $ with $ 2 \\leq n \\leq 100 $, $ 1 \\leq k \\leq n-1 $.  \nLet $ A = (a_1, a_2, \\dots, a_k) $ be a sequence of integers with $ 1 \\leq a_i \\leq 10^9 $.  \nLet $ C = \\{1, 2, \\dots, n\\} $ be the initial set of children.  \nLet $ L_0 = 1 $ be the initial leader.  \nFor step $ i \\in \\{1, \\dots, k\\} $, let $ C_i \\subseteq C $ be the set of remaining children before step $ i $, and $ L_{i-1} \\in C_{i-1} $ the current leader.\n\n**Constraints**  \n1. $ |C_0| = n $  \n2. For each $ i \\in \\{1, \\dots, k\\} $:  \n   - $ |C_{i-1}| = n - i + 1 $  \n   - $ a_i \\in \\mathbb{Z}^+ $  \n\n**Objective**  \nFor each step $ i = 1 $ to $ k $:  \n- Starting from the child immediately after $ L_{i-1} $, count $ a_i $ children clockwise in $ C_{i-1} $ (wrapping as needed).  \n- Let $ e_i \\in C_{i-1} $ be the child at the $ a_i $-th position (1-indexed count).  \n- Eliminate $ e_i $: $ C_i = C_{i-1} \\setminus \\{e_i\\} $.  \n- Set $ L_i $ to be the child immediately following $ e_i $ in $ C_i $ (clockwise).  \n- Output $ e_i $ for each step $ i $.  \n\nFormally, for step $ i $:  \nLet $ P = \\text{circular list of } C_{i-1} \\text{ ordered clockwise starting from } L_{i-1} $.  \nLet $ p = ( \\text{position of } L_{i-1} \\text{ in } P + 1 ) \\mod |C_{i-1}| $.  \nThen $ e_i = P_{(p + a_i - 1) \\mod |C_{i-1}|} $.  \nUpdate $ C_i = C_{i-1} \\setminus \\{e_i\\} $, and $ L_i = \\text{next child after } e_i \\text{ in } C_i $.","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF792B","tags":["implementation"],"sample_group":[["7 5\n10 4 11 4 1","4 2 5 6 1"],["3 2\n2 5","3 2"]],"created_at":"2026-03-03 11:00:39"}}