P1996 Josephus Problem
Description
$n$ people stand in a circle. Starting from the first person, they count off; the person who counts to $m$ leaves the circle. Then the next person resumes counting from $1$. The person who counts to $m$ leaves the circle again. Repeat this process until everyone has left the circle. Output the labels of the people who leave, in order.
Note: This problem differs slightly from the example in the book "深入浅出-基础篇". In the book, the description is to eliminate $n-1$ children, whereas this problem continues until everyone leaves the circle.
Input Format
Input two integers $n, m$.
Output Format
Output one line with $n$ integers: the labels of the people leaving the circle in order.
Explanation/Hint
$1 \le m, n \le 100$
Translated by ChatGPT 5