Cod sursa(job #1046823)
Utilizator | Data | 3 decembrie 2013 16:45:00 | |
---|---|---|---|
Problema | Invers modular | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.57 kb |
#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;
}