#MTH000000027. Tiệc trà điên rồ (Crazy Tea Party)
Tiệc trà điên rồ (Crazy Tea Party)
Crazy Tea Party
Source: UVa
Version: Phuoc Hung OJ Extended
Problem Statement
There are participants seated around a circular table. In each minute, exactly one pair of neighboring participants may swap places.
Find the minimum number of minutes required to reverse the circular order of all participants, so that every left neighbor becomes the corresponding right neighbor and vice versa.
Input
One integer , the number of participants.
Output
Print the minimum required time in minutes.
Subtasks
- Subtask 1 (20%): .
- Subtask 2 (30%): is even and .
- Subtask 3 (50%): Full constraints: .
Examples
Input
4
Output
2
Explanation
Write the initial circular order starting from participant 1 as 1 2 3 4.
The reversed order is 1 4 3 2.
It can be reached in two minutes:
- Swap neighboring participants
1and2. Rotating the written representation to start from1again gives1 3 4 2. - Participants
3and4are now adjacent; swapping them gives1 4 3 2.
One swap is not enough: relative to the initial order, participants 2 and 4 must exchange their positions, but they are not neighbors initially. Therefore the minimum time is 2.