Skip to content

UKSPC Practice Problems » Tickets

driver.c, driver.cpp, or
standard input
standard output

You have an infinite line of people, who are numbered with natural numbers, 1 through infinity. But tickets are not given out strictly FIFO, but in rounds. In round 1, the first person is given a ticket. In all subsequent ith rounds, the first person in line and every ith person after them is given a ticket. Once you have a ticket, you are removed from the line. Given a natural number n < MAX_INT, report the (ordinal) number of the first person to receive a ticket in the nth round.

Sample Input


Abbreviated Sample Output