Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <assert.h>
- #include <stdio.h>
- #include <stdlib.h>
- unsigned long long gcd(unsigned long long x, unsigned long long y, long long *a,
- long long *b) {
- unsigned long long d;
- long long a1 = 0, b1 = 0;
- if (y == 0) {
- *a = 1;
- *b = 0;
- return x;
- }
- d = gcd(y, x % y, &a1, &b1);
- *b = a1 - (x / y) * b1;
- *a = b1;
- return d;
- }
- int main() {
- unsigned long long x = 0, y = 0, g = 0;
- long long a = 10, b = 10;
- int res;
- res = scanf("%llu %llu", &x, &y);
- assert(res == 2);
- g = gcd(x, y, &a, &b);
- printf("%lld %lld %llu\n", a, b, g);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement