← All problemsSign in

Survivor

$N$ people are standing in a circle. They are numbered $1$, $2$, …, $N$ in continuous clockwise manner. The person numbered $1$ holds a gun. He shoots the person numbered $2$ and hands over the gun to the person numbered $3$, who then shoots the person numbered $4$ and hands over the gun to the person numbered $5$. This continues until only one person remains. You are given the number of persons s

HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17

CodeSearch Tutor

Hints, not spoilers — it won’t hand over the full solution unless you insist.

voice by Sarvam AI

Sign in to chat with the tutor and save your progress.

Sign in to start