【杭电ACM】1.2.3 hide handkerchief
【杭电ACM】1.2.3 hide handkerchief
http://acm.hdu.edu.cn/game/entry/problem/show.php?chapterid=1§ionid=2&problemid=61 #include <iostream> 2 using namespace std; 3 4 int gcd(int a, int b){ 5 if(b == 0) 6 return a; 7 return gcd(b, a % b); 8 } 9 10 bool relativelyPrime(int a, int b){ 11 if(gcd(a, b) == 1) 12 return true; 13 else 14 return false; 15 } 16 int main(){ 17 int n, m; 18 while(cin >> n >> m){ 19 if(n == -1 && m == -1) 20 break; 21 if(relativelyPrime(n , m)) 22 cout << "YES" << endl; 23 else 24 cout << "POOR Haha" << endl; 25 } 26 return 0; 27 }