Pagini recente » Cod sursa (job #2860703) | Cod sursa (job #2483412) | Cod sursa (job #150259) | Cod sursa (job #1647819) | Cod sursa (job #2822525)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("inversmodular.in");
ofstream fout("inversmodular.out");
void Euclid(int a, int b, long long & x, long long & y)
{
if(b == 0)
{
x = 1;
y = 0;
}
else
{
long long x1, y1;
Euclid(b, a % b, x1, y1);
x = y1;
y = x1 - y1 * (a / b);
}
}
int main()
{
int a, n;
fin >> a >> n;
long long x, y;
Euclid(a, n, x, y);
fout << x;
return 0;
}