#include <stdio.h> #include <string.h> #include <iostream> #include <string> using namespace std; typedef long long LL; int extgcd(int a, int b, LL &d, LL &x, LL &y) { if (b == 0) { d = a; x = 1; y = 0; } else { extgcd(b, a % b, d, y, x); y -= x * (a / b); } } int main() { LL x, y, d; extgcd(15, 6, d, x, y); cout << "gcd(a, b) = " << d << endl; cout << "x = " << x << endl; cout << "y = " << y << endl; system("pause"); return 0; }