标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 6052 Accepted Submission(s): 3032
题解:就是求n和m 是否互质,求gcd(n,m)是否等于1即可
代码:
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 using namespace std; 5 int gcd (int a , int b) 6 { 7 return b==0? a :gcd(b,a%b); 8 } 9 int main() 10 { 11 int n , m ; 12 int t ; 13 cin>>t; 14 while(t--) 15 { 16 scanf("%d%d",&n,&m); 17 if(gcd(n,m)==1) 18 cout<<"NO"<<endl; 19 else cout<<"YES"<<endl; 20 } 21 return 0; 22 }
标签:
原文地址:http://www.cnblogs.com/shanyr/p/4675865.html