WA了两发,一直想不通,有没有大佬帮帮忙
查看原帖
WA了两发,一直想不通,有没有大佬帮帮忙
195670
孙cy楼主2020/7/21 10:03
#include <iostream>
#include <cmath>
using namespace std;
int gcd(int a, int b)
{
	if (a % b == 0)
		return b;
	else
		return gcd(b, a % b);
}
int main()
{
	int n;
	cin >> n;
	while (n--)
	{
		int ax, ay, bx, by;
		cin >> ax >> ay >> bx >> by;
		if ((ax == bx) || (ay == by))//坑2:特判
		{
			if (((bx - ax) + (by - ay)) > 1)
				cout << "yes" << endl;
			else
				cout << "no" << endl;
			continue;
		}
		if (gcd(abs(bx - ax), abs(by - ay)) == 1)//坑1:绝对值
			cout << "no" << endl;
		else
			cout << "yes" << endl;
	}
	return 0;
}
2020/7/21 10:03
加载中...