要满足Euclidean distance,可以是y1-y2==0 或x1-x2==0 或y1-y2==0且x1-x2==0 或y1-y2!=0并且x1-x2!=0但是平方和开根号为整数,那么也就是说到达一个点可以横着走竖着走斜着走,到达一个点最多需要经过两条路。如果经过一条路到达不了的点,经过两条路一定能到。
#include<bits/stdc++.h>
using namespace std;
int main(){
ios::sync_wih_stdio(false);
cin.tie(0);
int t;
cin>>t;
while(t--){
int x,y,n=2;
cin>>x>>y;
if(x==0&&y==0){
cout<<n-2<<endl;
}
else if((int)sqrt(x*x+y*y)==sqrt(x*x+y*y)){
cout<<n-1<<endl;
}
else{
cout<<n<<endl;
}
}
return 0;
}