#P6791. [SNOI2020] 取石子
[SNOI2020] 取石子
Description
Player A and Player B play a stone-taking game. There is a pile of stones. Player A moves first, and they take turns removing stones from the pile:
- On Player A's first move, the number of stones taken cannot exceed .
- After that, on each move, the number of stones taken cannot exceed times the number taken by the previous player.
- Each player must take at least one stone each turn.
The player who takes the last stone loses, and the other player wins.
Given , find how many integers in make Player A have a winning strategy in the game with stones.
Input Format
Multiple test cases.
The first line contains a positive integer , the number of test cases.
The next lines each contain two integers and separated by a space, representing one query.
Output Format
Output lines. In the input order, each line contains one integer, the answer for that query.
3
1 5
2 5
1 10
2
3
4
Hint
Sample Explanation
For sample , when :
- If , Player A can only take the only stone and thus loses.
- If , Player A takes one stone, Player B must take the last stone, and Player A wins.
- If , Player A can only take one stone, Player B then takes one stone, and Player A must take the last stone and thus loses.
- If , Player A can only take one stone, Player B then takes two stones, and Player A must take the last stone and thus loses.
- If , Player A can only take one stone. Player B can only take one or two stones, and Player A can always leave Player B the last stone, thus winning.
Data Notes and Hints
For all testdata, .
- For of the testdata, .
- For another of the testdata, .
- For another of the testdata, .
- For another of the testdata, .
- For the remaining of the testdata, there are no special constraints.
Translated by ChatGPT 5
京公网安备 11011102002149号