CF1657A.Integer Moves
入门
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
There's a chip in the point (0,0) of the coordinate plane. In one operation, you can move the chip from some point (x1,y1) to some point (x2,y2) if the Euclidean distance between these two points is an integer (i.e. (x1−x2)2+(y1−y2)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).
坐标平面上的点 (0,0) 处有一个芯片。在一次操作中,你可以将芯片从某点 (x1,y1) 移动到某点 (x2,y2),当且仅当这两点之间的欧几里得距离为整数(即 (x1−x2)2+(y1−y2)2 为整数)。
你的任务是确定将芯片从点 (0,0) 移动到点 (x,y) 所需的最少操作次数。
输入格式
The first line contains a single integer t (1≤t≤3000) — number of test cases.
The single line of each test case contains two integers x and y (0≤x,y≤50) — the coordinates of the destination point.
第一行包含一个整数 t(1≤t≤3000)—— 测试用例的数量。
每个测试用例的单行包含两个整数 x 和 y(0≤x,y≤50)—— 目标点的坐标。
输出格式
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).
对于每个测试用例,输出一个整数——将筹码从点 (0,0) 移动到点 (x,y) 所需的最少操作次数。
输入输出样例
输入#1
3 8 6 0 0 9 15
输出#1
1 0 2
说明/提示
In the first example, one operation (0,0)→(8,6) is enough. (0−8)2+(0−6)2=64+36=100=10 is an integer.
In the second example, the chip is already at the destination point.
In the third example, the chip can be moved as follows: (0,0)→(5,12)→(9,15). (0−5)2+(0−12)2=25+144=169=13 and (5−9)2+(12−15)2=16+9=25=5 are integers.
在第一个例子中,只需一次操作 (0,0)→(8,6) 即可。(0−8)2+(0−6)2=64+36=100=10 是整数。
在第二个例子中,棋子已位于目标点。
在第三个例子中,棋子可按如下方式移动:(0,0)→(5,12)→(9,15)。(0−5)2+(0−12)2=25+144=169=13 和 (5−9)2+(12−15)2=16+9=25=5 均为整数。
输入解题思路,AI测评打分。不知道怎么写?