Josephus Again
CodeChefOpen on judge ↗
Perhaps you know about the famous Josephus problem where some hapless people are standing in a circle waiting to be executed. Here, our problem is a little bit different in which computational efficiency is more important. After losing a battle, $n$ soldiers, with unique integer IDs $1, 2, \ldots, n$ are standing in a circle. Counting from 1 (The soldier with ID 1 is counted 1) every $k^{th}$ ($1
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.
Sign in to chat with the tutor and save your progress.
Sign in to start