最后幸存者
Last One Standing
题目详情
假设有 100 个人围成一圈,编号为 1 到 100。1 号拿到一把剑并淘汰 2 号;3 号捡起剑再淘汰 4 号,以此类推。这个过程持续进行,直到只剩下一个人。最后幸存者是谁?
英文原题
Suppose there are 100 people standing in a circle numbered 1-100. Person 1 is given a sword and uses it to slay person 2. Person 3 picks up the sword and uses it to eliminate person 4 and so on. This continues until just one person remains. Which person is the survivor?
解析
这是步长为 2 的经典 Josephus 问题。
对 个人、每次淘汰下一个人,幸存者位置满足
其中
且 是不超过 的最大 2 的幂。
这里 ,因为
所以
于是
因此最后的幸存者是
英文解析
This is the classic Josephus problem with and step .
We can write
where is the largest power of not exceeding .
The survivor is given by
For , we have ,
so and .
Hence