远端评测题 1000ms 125MiB

约瑟夫问题

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Description

nn people stand in a circle. Starting from the first person, they count off; the person who counts to mm leaves the circle. Then the next person resumes counting from 11. The person who counts to mm 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 n1n-1 children, whereas this problem continues until everyone leaves the circle.

Input Format

Input two integers n,mn, m.

Output Format

Output one line with nn integers: the labels of the people leaving the circle in order.

10 3
3 6 9 2 7 1 8 5 10 4

Hint

1m,n1001 \le m, n \le 100

Translated by ChatGPT 5

第 24 课:模拟算法

未认领
状态
已结束
题目
15
开始时间
2026-7-6 22:00
截止时间
2026-7-13 22:00
可延期
24 小时