|
楼主 |
发表于 2021-10-6 20:10:01
From FishC Mobile
|
显示全部楼层
Question: (Josephus Problem)
n individuals labeled from 1 to n form a circle, which means the next person of the n-th person
is the first person. Counting begins at the first person, and the m-th person counted will go out.
Then the counting restart at the next person of the one who went out, and still the m-th person
counted will go out. Repeat the counting until all of the people have gone out.
In this problem, given n and m, please show the order they went out.
Input
A single line containing two integers n and m separated by a space.
Output
Print n integers in a single line denoting the labels of these n persons and indicating the order
they went out. Please separate each two of these integers by a single space.
Constraint:
1≤n,n≤10^4 |
|