abs(tx-lx)或abs(ty-ly)有可能为0,算gcd会无限循环,加入特判就行了
```cpp
#include<bits/stdc++.h>
using namespace std;
int abc(int a,int b){
return (a==b)?a:abc(abs(a-b),min(a,b));
}
int main(){
int tx,ty,lx,ly,n;
cin>>n;
for(int i=0;i<n;i++){
cin>>lx>>ly>>tx>>ty;
if(abs(tx-lx)==0||abs(ty-ly)==0)
{
if(max(abs(tx-lx),abs(ty-ly))>1){
cout<<"yes\n";
}
else{
cout<<"no\n";
}
}
else if(abc(abs(tx-lx),abs(ty-ly))==1){
cout<<"no\n";
}
else{
cout<<"yes\n";
}
}
return 0;
}
```
[记录](https://www.luogu.com.cn/record/143171527)
by imnoob @ 2024-01-17 21:05:39