#P7573. 「PMOI-3」公平正义

「PMOI-3」公平正义

Description

There are now nn people, and lhm has a cake of mass 11. Everyone wants to eat lhm’s cake. To maintain fairness and justice, lhm needs to use the minimum number of cuts to divide the cake into nn equal shares (one share may contain multiple pieces).

Treat the cake as a circle. Note that each time you cut the cake, you can only cut along a diameter.

In the end, the number of pieces each person gets may be different, but you must ensure that each person receives mass 1n\frac{1}{n}.

You need to find the minimum number of cuts lhm needs to make.

Input Format

This problem contains multiple test cases.

The input has t+1t+1 lines.

The first line contains an integer tt, representing the number of test cases.

The next tt lines each contain an integer nn, representing the number of people.

Output Format

Output tt lines. Each line contains a positive integer, representing the answer.

2
2
3
1
2

Hint

[Sample Explanation]

When n=2n=2, we cut directly along a diameter, obtaining two cake pieces each of mass 12\frac{1}{2}. Give them to the two people.

When n=3n=3, we can cut along two diameters with an angle of 60°60 \degree between them, obtaining two pieces a,ba,b of mass 16\frac{1}{6} and two pieces c,dc,d of mass 13\frac{1}{3}. We give a,ba,b to the first person, and give c,dc,d to the second and third person respectively, achieving fairness and justice.

[Constraints]

For 20%20\% of the testdata, 1n101 \le n \le 10.

For another 20%20\% of the testdata, t=1t=1.

For 100%100\% of the testdata, 1t1031 \le t \le 10^3, 1n1091 \le n \le 10^{9}.

Translated by ChatGPT 5