Advertisement
Guest User

Untitled

a guest
Sep 19th, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #include <assert.h>
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4.  
  5. unsigned long long gcd(unsigned long long x, unsigned long long y, long long *a,
  6. long long *b) {
  7. unsigned long long d;
  8. long long a1 = 0, b1 = 0;
  9. if (y == 0) {
  10. *a = 1;
  11. *b = 0;
  12. return x;
  13. }
  14. d = gcd(y, x % y, &a1, &b1);
  15. *b = a1 - (x / y) * b1;
  16. *a = b1;
  17. return d;
  18. }
  19.  
  20. int main() {
  21. unsigned long long x = 0, y = 0, g = 0;
  22. long long a = 10, b = 10;
  23. int res;
  24. res = scanf("%llu %llu", &x, &y);
  25. assert(res == 2);
  26. g = gcd(x, y, &a, &b);
  27. printf("%lld %lld %llu\n", a, b, g);
  28. return 0;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement