#P11565. 【MX-X7-T6】[LSOT-3] 棋盘
【MX-X7-T6】[LSOT-3] 棋盘
Background
Original link: https://oier.team/problems/X7G.
There is now a sequence.
The st term of this sequence is , the nd term is , the rd term is , and the th term is .
Now @lxwtr asks you what the value of the -th term is.
Problem Description
Alice and Bob found a chessboard. The chessboard can be viewed as a number line. Initially, there are pieces at the origin. Let denote the number of pieces at position on the number line (the origin is ). Each time, the player finds the smallest such that , decreases by , and then chooses either to increase by or to increase by . Alice moves first, and they take turns operating. A player must make a move; if no such can be found, the game ends immediately.
Alice wants the total number of moves made by both players to be as small as possible, while Bob wants the total number of moves made by both players to be as large as possible. Both players are perfectly smart. They played games in total, and you want to know, for each game, how many moves in total will be made in the end.
Input Format
The first line contains a positive integer , representing the number of games played.
The next lines each contain a positive integer , representing the number of pieces at the origin at the start of each game.
Output Format
Output lines. The -th line contains a non-negative integer, representing the total number of moves made by both players in the -th game.
6
1
2
3
4
100
100000
0
1
1
3
95
99989
Hint
Sample Explanation
For the first game, the number of pieces at the origin is , so no move can be made.
For the second game, exactly one move can be made, after which or . Either way, no further move can be made.
For the third game, it is similar to the second game, except that one extra piece is left at the origin.
For the fourth game, no matter where Alice places the piece after the first move, Bob can place it at the same position, so Alice will make one more move. There are moves in total.
Constraints
This problem uses bundled testdata.
- Subtask 1 (5 points): .
- Subtask 2 (6 points): .
- Subtask 3 (14 points): .
- Subtask 4 (20 points): .
- Subtask 5 (21 points): .
- Subtask 6 (34 points): no special properties.
For all testdata, , .
Translated by ChatGPT 5