扩展欧几里得
程序员文章站
2024-02-11 16:45:16
...
#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;
}
上一篇: Oracle读取数据错误和hibernate几个问题
下一篇: 一个心理测评网站的付费功能如何实现