Advertisement
Guest User

Untitled

a guest
Jul 28th, 2021
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. void solve() {
  2. ll x, y; cin >> x >> y;
  3. ll mn = min(x, y);
  4. ll mx = max(x, y);
  5. ll ans1 = INT_MAX, ans2 = INT_MAX, ans3 = INT_MAX;
  6. if (x % 2 == 0 and y % 2 == 0) {
  7. cout << 0;
  8. return;
  9. }
  10. // else if (x == 1 or y == 1)
  11. // { cout << 1;
  12. // return;
  13. // }
  14. else if ( x == y) {
  15. cout << 0;
  16. return;
  17. }
  18. else {
  19. if (__gcd(x + 1, y) > 1) {
  20. ans1 = 1 ;
  21. if (__gcd(x + 1, y) <= 1)
  22. ans1++;
  23. }
  24. if (__gcd(y + 1, x) > 1) {
  25. ans2 = 1;
  26. if (__gcd(y + 1, x) <= 1)
  27. ans2++;
  28. }
  29. if (__gcd(x + 1, y + 1) > 1) {
  30. ans3 = 2;
  31. }
  32. }
  33. cout << min({ans1, ans2, ans3});
  34. // error(no);
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement