By Vinícius "Cabessa" Fernandes dos Santos Brazil
A card pack has an even number 2n of cards a1 , a2 , . . . , a2n , all distinct (a1 < a2 < · · · < a2n ). The pack is initially sorted, that is, the first card in the pack is a1 , the second is a2 , and so on, and the last card in the pack is a2n.
A handler then performs a shuffling procedure repeatedly. The shuffling consists of two steps:
Given the number of cards in the pack, write a program to determine how many times the shuffling
procedure must be executed so that the pack becomes sorted again.
The input contains several test cases. A test case consists of one line, which contains an even integer P (2 ≤ P ≤ 2 x 105 ), where P is the number of cards in the pack (notice that the value P corresponds to the value 2n in the description above).
For each test case in the input your program must produce a single line, containing a single integer, the minimum number of times the shuffling procedure must be executed so that the set becomes sorted again.
Sample Input | Sample Output |
6 |
3 |