欧几里德扩展定理
1 #include <iostream> 2 using namespace std; 3 int gcd(int a,int b) 4 { 5 return !b?a:gcd(b,a%b); 6 } 7 int main() 8 { 9 int sum; 10 cin>>sum; 11 while(sum--) 12 { 13 int a,b; 14 cin>>a>>b; 15 if(gcd(a,b)==1) cout<<"NO"<<endl; 16 else cout<<"YES"<<endl; 17 } 18 return 0; 19 }