http://acm.hdu.edu.cn/showproblem.php?pid=1222

理解题目:

当两者公约数为1,不存在安全洞。

不为1时,存在安全洞。

#include<stdio.h>
int gcd(int n,int m)
{
 if(m==0) return n;
 return gcd(m,n%m);
}
int main()
{
 int a,b,t;
 scanf("%d",&t);
 while(t--){
  scanf("%d %d",&a,&b);
  if(gcd(a,b)==1)
   printf("NO\n");
  else
   printf("YES\n");
 
 }
}

posted on 2009-05-01 01:04  pandy  阅读(298)  评论(0编辑  收藏  举报