309284: CF1657A. Integer Moves
Memory Limit:256 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Integer Moves
题意翻译
一个点一开始在二维平面的原点,即 $(0,0)$,每一步它可以移动到任意一个与其距离为整数的点。现在,给定两个整数 $x,y$,求最少要多少步才能够从 $(0,0)$ 走到 $(x,y)$。 数据范围: - $t$ 组数据,$1\leqslant t\leqslant 3000$。 - $0\leqslant x,y\leqslant 50$。 Translated by Eason_AC题目描述
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