跳转至

Josephus ring

output a order -> queue

The Josephus problem can be simulated using a standard queue.

Move the front element to the back of the queue M−1 times, then permanently remove the front element—the M-th element.

Repeat this process until only one element remains.

约瑟夫环问题可以用标准队列模拟。

重复执行 M−1 次“从队头出队,再入队到队尾”的操作,然后将当前队首,也就是第 M 个元素,永久移除。

重复此过程,直到只剩下一个元素。