题库练习 Integer Moves
← 上一题 下一题 →

A14888 | Integer Moves

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

题目描述

There's a chip in the point $(0, 0)$ of the coordinate plane. In one operation, you can move the chip from some point $(x_1, y_1)$ to some point $(x_2, y_2)$ if the Euclidean distance between these two points is an integer (i.e. $\sqrt{(x_1-x_2)^2+(y_1-y_2)^2}$ is integer).

Your task is to determine the minimum number of operations required to move the chip from the point $(0, 0)$ to the point $(x, y)$ .

输入格式

The first line contains a single integer $t$ ( $1 \le t \le 3000$ ) — number of test cases.

The single line of each test case contains two integers $x$ and $y$ ( $0 \le x, y \le 50$ ) — the coordinates of the destination point.

输出格式

For each test case, print one integer — the minimum number of operations required to move the chip from the point $(0, 0)$ to the point $(x, y)$ .

输入输出样例

输入 #1
3
8 6
0 0
9 15
输出 #1
1
0
2
C++ 编辑器
输入
输出