-->
当前位置:首页 > 题库

PROGRAMMING:number off

Luz5年前 (2021-05-10)题库485
Enter two positive integers n and m ((1 < m < n < = 50)), there are n people in a circle, numbered from 1 to N in order. Start counting from the first person, and the person who counts m quits the circle. The next person starts counting again from 1, and the person who counts m quits the circle. This cycle, until the last person is left. Please output the number of the person who quit the circle and the number of the last person according to the exit order.
Tip: save the number of each person in the array, start counting from the first person, output the number of the person who reported the number m, clear the number to 0, and repeat this operation until there is only one number that is not 0, which is the number of the last person.
Input and output example: description in brackets, no input and output required
###Input example:
```in
5 (n persons, n = 5)
3 (number M = 3)
```
###Output example:
```out
No1: 3
No2: 1 ( The number of the second person to quit the circle is 1)
No3: 5 ( The number of the third person who quit the circle is 5)
No4: 2 ( The number of the fourth person who quit the circle is 2)
Last no is: 4
```






answer:If there is no answer, please comment