扩展gcd
#include <iostream>
#include <cmath>
using namespace std;
void Egcd(int a, int b, int arr[]) {
while (b != 0) {
int tim = a / b, temp = b;
b = a % b;
a = temp;
arr[0] -= tim * arr[2];
swap(arr[0], arr[2]);
arr[1] -= tim * arr[3];
swap(arr[1], arr[3]);
}
}
int main() {
int a, b, arr[4] = {1, 0, 0, 1};
cin >> a >> b;
if (a < b)
swap(a, b);
Egcd(a, b, arr);
cout << arr[0] << ' ' << arr[1];
return 0;
}