エクスパンダ
947 ワード
#pragma GCC optimize(3)
#include
#define mst(a,b) memset(a,b,sizeof(a))
#define For(i, k, j) for(int i = (k); i <= (j); i++)
#define INF 2147483647/3
#define ll long long
using namespace std;
inline int read()
{
int num = 0, flag = 1;
char c=' ';
for(;c>'9'||c='0'&&c<='9';num=(num<<1)+(num<<3)+c-48,c=getchar());
return num * flag;
}
int exgcd(int a, int b, int &x, int &y) {
if(b == 0) {
x = 1; y = 0;
return a;
}
int r = exgcd(b, a % b, x, y);
int t = x;
x = y;
y = t - a / b * y;
return r;
}
int main() {
int a, b, x, y;
cin >> a >> b;
int d = exgcd(a, b, x, y);
cout << a << " * " << x << " + " << b << " * " << y << " = " << d << endl;
return 0;
}