First of all, the problem: n individuals (numbered 0-n-1) in a circle, starting from 1 to count, reporting m of the people out, and then from the people of the next person, starting from 1, starting off, report m of the people out, to find the last surviving the original number of the person.
It is not difficult to implement if you are simply simulating the entire game. What I learned today is another algorithm. For example, after the first round, assuming the elimination of the person number is k-1, Count is M, then the next n-1 should be such a sort of X ' (x), X ' indicates the number of the previous round, X represents the number of the round. So the current situation should be such that K (0), k+1 (1), k+2 (2) 、......、 k-2 (n-2), we can draw such a formula X ' = (x+k)%n because the last survivor his final number must be 0, then there is this launch his last round number ... Until the first number is released.
Joseph Ring algorithm