#include <iostream>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cstdio>
#include <vector>
#include <queue>
#include <limits>
using namespace std;
typedef long long ll;
const int MAXN = 100005;
int extgcd(int a, int b, int &x, int &y)
{
if (b == 0)
{
x = 1;
y = 0;
return a;
}
int xx, yy;
int ret = extgcd(b, a % b, xx, yy);
x = yy;
y = xx - (a / b) * yy;
return ret;
}
int main()
{
freopen("in.txt", "r", stdin);
freopen("out.txt", "w", stdout);
ios::sync_with_stdio(false);
cin.tie(0);
int x, y;
extgcd(4, 11, x, y);
cout << x << " " << y;
return 0;
}
擴展歐幾里得
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.