Fortune Telling Collection - Comprehensive fortune-telling - Josephus, the famous josephus problem

Josephus, the famous josephus problem

It is said that the famous Jewish historian Josephus has a story: After the Romans occupied Jotapat, 39 Jews hid in a cave with Josephus and his friends, and 39 Jews decided to die rather than surrender, so they decided to commit suicide. 4 1 people form a circle. Count from 1, and every time you count to the third person, that person will commit suicide.

However, Josephus and his friends didn't want to obey. Josephus asked his friend to pretend to obey first. He arranged his friends and himself in the positions of 16 and 3 1, thus avoiding the game of death.

solution

Josephus problem can solve this problem by algebraic analysis, which expands the problem. Suppose you and M friends are unfortunately involved in this game now, how do you protect your friends? Just draw two circles and you can save yourself and your friends from the game of death. The inner circle of these two circles is the arrangement order, and the outer circle is the suicide order, as shown in the following figure: