看下我的思路和代码,求指导(0pts)
查看原帖
看下我的思路和代码,求指导(0pts)
1347790
zjck2楼主2024/7/22 11:11

直接判断兔八哥对于猎人的横纵坐标之差的绝对值,然后判断其是否互质(题解一楼的思路)

#include<bits/stdc++.h>
using namespace std;
bool huzhi(int a,int b){
	for(int i=2;i<=a;i++){
		if(a%i==0){//判断i对a 
			if(b%i==0){//判断i对b 
				return false;//不互质 
			}
		}
	}
	return true;//互质 
}
int gcd(int x,int y){
	if(x<=1||y<=1) return 0;
	if(huzhi(x,y)) return 1;
	else return 0;
}
int main(){
	int n;
	cin>>n;
	while(n--){
		int tx,ty,lx,ly;
		cin>>lx>>ly>>tx>>ty;
		if(abs(lx-tx),abs(ly-ty)==1) cout<<"no"<<endl;
		else cout<<"yes"<<endl;
	}
	return 0;
}
2024/7/22 11:11
加载中...