Pagini recente » Cod sursa (job #464391) | Cod sursa (job #344506) | Cod sursa (job #485174) | Cod sursa (job #2553256) | Cod sursa (job #1046823)
#include <cstdio>
long long A, N, x, y;
void cmmdc(long long a, long long b, long long &x, long long &y)
{
long long x1, y1;
if (b)
{
cmmdc(b, a % b, x1, y1);
x = y1;
y = x1 - y1 * (a / b);
return;
}
x = 1;
y = 0;
}
void Citire()
{
scanf("%lld %lld", &A, &N);
}
void Rezolvare()
{
cmmdc(A, N, x, y);
printf("%lld", x);
}
int main()
{
freopen("inversmodular.in", "r", stdin);
freopen("inversmodular.out", "w", stdout);
Citire();
Rezolvare();
return 0;
}