#P1996. 约瑟夫问题
约瑟夫问题
Description
people stand in a circle. Starting from the first person, they count off; the person who counts to leaves the circle. Then the next person resumes counting from . The person who counts to 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 children, whereas this problem continues until everyone leaves the circle.
Input Format
Input two integers .
Output Format
Output one line with integers: the labels of the people leaving the circle in order.
10 3
3 6 9 2 7 1 8 5 10 4
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号