AC日记——可能的路径 51nod 1247

可能的路径

思路:

  看到题目想到gcd;

  仔细一看是更相减损;

  而gcd是更相减损的优化版;

  所以,对于每组数据判断gcd是否相等就好;

来,上代码:

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; inline void in(long long &now)
{
char Cget=getchar();now=;
while(Cget>''||Cget<'') Cget=getchar();
while(Cget>=''&&Cget<='')
{
now=now*+Cget-'';
Cget=getchar();
}
} inline long long gcd(long long a,long long b)
{
return b==?a:gcd(b,a%b);
} int main()
{
long long t,a,b,x,y;
in(t);
while(t--)
{
in(a),in(b),in(x),in(y);
if(gcd(a,b)==gcd(x,y)) printf("Yes\n");
else printf("No\n");
}
return ;
}
上一篇:51nod 1247 可能的路径(gcd)


下一篇:Dubbo多版本