您的位置:首页 > 其它

51nod_1247可能的路径

2017-07-24 16:28 330 查看



#include<iostream>
#include<cstdio>
#include<cstring>
#include<vector>
#include<algorithm>
#include<map>
#include<string>

using namespace std;

int t;
long long a, b;
long long c, d;

long long gcd(long long x, long long y)
{
return y == 0 ? x : gcd(y, x%y);
}

long long extgcd(long long a, long long b, long long &x, long long &y)
{
if (b == 0)
{
x = 1;y = 0;
return a;
}

long long r = extgcd(b, a%b, x, y);

long long t = x;
x = y;
y = t - a / b*y;

return r;
}

int main()
{
scanf("%d", &t);
while (t--)
{
scanf("%lld %lld %lld %lld", &a, &b, &c, &d);

if (gcd(a,b)==gcd(c,d))
printf("Yes\n");
else
printf("No\n");
}

return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: