Troubled Treasure


Submit solution

Points: 10 (partial)
Time limit: 1.0s
Memory limit: 250M

Authors:
Problem type

At last they reach the Treasure Castle, the final destination. There are n boxes numbered from 1 to n arranged in a circular fashion in the clockwise direction. Only one of the boxes have the treasure in it. The box can be identified by doing the following steps until only one box is left: Starting from box 1, keep discarding every other box in the clockwise order, until only one box remains. Once a box is discarded, it disappears. The box that remains at the last is the treasure box that contains 100 Bitcoins. Help them find the correct treasure box.

Input:

The only line of the input contains n , the number of boxes.

Output:

A single integer , that is the number on the treasure box.

Constraints:

1 <= n <= \(10^4\)

Sample Input:

5

Sample Output:

2

Explanation:

The order in which boxes are pushed down: 1 -> 3 -> 5 -> 4.

The treasure box 2 will remain at the last.


Comments


  • 0
    nagulan_s  commented on Sept. 6, 2018, 12:31 p.m.

    more examples please.....


    • 1
      knn  commented on Sept. 19, 2018, 9:48 a.m. edited

      It is not necessary to add explanation always. There are many problems which do this. Adding explanation depends on the setting panel. If statement is not clear, you can clarify. P.S : No hints.