Pagini recente » Cod sursa (job #557781) | Cod sursa (job #674422) | Cod sursa (job #2231474) | Cod sursa (job #3162286) | 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;
}