Advertisement
Tolyamba

Untitled

Jun 14th, 2016
189
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.46 KB | None | 0 0
  1. // CF_TR4_A
  2. #define _CRT_SECURE_NO_WARNINGS
  3. #include <iostream>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. int gcd(int x, int y)
  9. {
  10.     if (x == 0) return y;
  11.     else return gcd(y%x, x);
  12. }
  13.  
  14. int main()
  15. {
  16.     long long x1, y1, x2, y2, k = 0, a, b;
  17.     cin >> x1 >> y1 >> x2 >> y2;
  18.     //scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
  19.      a = abs(x2 - x1);
  20.      b = abs (y2 - y1);
  21.      k = gcd (a,b);
  22.  
  23.     //cout << k;
  24.     printf("%d", k+1);
  25.     //system("pause");
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement