fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3. int main() {
  4. int n, m, p;
  5. while(cin >> n >> m) {
  6. if (m > n) { //NOD
  7. p = n;
  8. n = m;
  9. m = p;
  10. }
  11. while (m > 0) {
  12. p = n % m;
  13. if (p != 0) {
  14. n = m;
  15. m = p;
  16. }
  17. else break;
  18. }
  19. cout<<(m==1?"YES": "NO")<<endl;
  20. }
  21. return 0;
  22. }
Success #stdin #stdout 0s 3460KB
stdin
4 1
6 3
stdout
YES
NO