题库练习 Subtraction Game
← 上一题 下一题 →

A16007 | Subtraction Game

时间限制1s
内存限制256MB
通过 / 提交0/0

题目描述

You are given two positive integers, $a$ and $b$ ( $a < b$ ).

For some positive integer $n$ , two players will play a game starting with a pile of $n$ stones. They take turns removing exactly $a$ or exactly $b$ stones from the pile. The player who is unable to make a move loses.

Find a positive integer $n$ such that the second player to move in this game has a winning strategy. This means that no matter what moves the first player makes, the second player can carefully choose their moves (possibly depending on the first player's moves) to ensure they win.

输入格式

Each test contains multiple test cases. The first line contains the number of test cases $t$ ( $1 \le t \le 100$ ). The description of the test cases follows.

The only line of each test case contains two integers, $a$ and $b$ ( $1 \le a < b \le 100$ ).

输出格式

For each test case, output any positive integer $n$ ( $1 \le n \le 10^6$ ) such that the second player to move wins.

It can be proven that such an $n$ always exists under the constraints of the problem.

输入输出样例

输入 #1
3
1 4
1 5
9 26
输出 #1
2
6
3
C++ 编辑器
输入
输出