#P10892. SDOI2024

SDOI2024

Background

AzureHair was defeated by “Meow Meow” in NOIP 2022, and then got an incurable illness—fear of T2. So in NOIP 2023, he firmly skipped T2 and then spent two hours stuck on T3 with no result, leaving regretfully. His classmates decided to help him cure this incurable illness.

After his classmates cured his fear of T2, he confidently started his SDOI. Then he spent 22 hours writing a partial solution but still could not finish, and left regretfully again.

Problem Description

AzureHair’s classmates lock AzureHair and nn cats in a room, and require that every day AzureHair hands over n2\frac{n}{2} cats. But if nn is odd, AzureHair will struggle with whether to hand over n+12\frac{n+1}{2} cats or n12\frac{n-1}{2} cats. AzureHair does not want to struggle, so please compute the minimum number of times he must struggle until all cats are taken out of the room.

Input Format

This problem has multiple test cases.

The first line contains an integer TT.

The next TT lines each contain one integer nn.

Output Format

Output TT lines, each containing one integer representing the minimum number of times he struggles.

2
13
7
3
2

Hint

Sample Explanation

For 1313 cats, one process with only 33 struggles is as follows:

Choose to hand over 77 cats, leaving 66;

No struggle, hand over 33 cats, leaving 33;

Choose to hand over 22 cats, leaving 11;

Choose to hand over 11 cat, and all cats are taken away.

It is easy to prove that there is no plan with fewer than 33 struggles.

Constraints

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

For 30%30\% of the testdata, 1n1051 \le n \le 10^{5}.

For 100%100\% of the testdata, 1n2601 \le n \le 2^{60}, 1T5×1051 \le T \le 5 \times 10^5.

Translated by ChatGPT 5