Prison
Time limit2sMemory limit512 MB
Simulate a process that repeatedly removes multiples of k from an infinite list of prisoners and renumbers, then report the original label released on step N.
- Level
Hard8 of 10
- Topics
- Math, Combinatorics, Simulation, Number theory
- Solved
- No attempts yet
Problem
There are infinitely many prisoners. Initially, the prisoners are numbered .
Perform the following operation times.
- Release prisoner , and execute prisoners .
- Then renumber the remaining prisoners. At this time, number them in order from the prisoner with the smallest original number.
Find the number originally assigned to the prisoner released in the -th operation.
Input
The input is given from standard input in the following format.
Output
Output the answer on one line.
Constraints
- The answer is at most .