A10940 | Counting-out Rhyme
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
$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.
For 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.
You have to write a program which prints the number of the child to be eliminated on every step.
For 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.
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 $n$ and $k$ ( $2<=n<=100$ , $1<=k<=n-1$ ).
The next line contains $k$ integer numbers $a_{1},a_{2},...,a_{k}$ ( $1<=a_{i}<=10^{9}$ ).
The next line contains $k$ integer numbers $a_{1},a_{2},...,a_{k}$ ( $1<=a_{i}<=10^{9}$ ).
输出格式
Print $k$ numbers, the $i$ -th one corresponds to the number of child to be eliminated at the $i$ -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 $4$ is eliminated, child $5$ becomes the leader.
- In the second step child $2$ is eliminated, child $3$ becomes the leader.
- In the third step child $5$ is eliminated, child $6$ becomes the leader.
- In the fourth step child $6$ is eliminated, child $7$ becomes the leader.
- In the final step child $1$ is eliminated, child $3$ becomes the leader.
- In the first step child $4$ is eliminated, child $5$ becomes the leader.
- In the second step child $2$ is eliminated, child $3$ becomes the leader.
- In the third step child $5$ is eliminated, child $6$ becomes the leader.
- In the fourth step child $6$ is eliminated, child $7$ becomes the leader.
- In the final step child $1$ is eliminated, child $3$ becomes the leader.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted