Cod sursa(job #300557)
Utilizator | Data | 7 aprilie 2009 15:15:23 | |
---|---|---|---|
Problema | Invers modular | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.34 kb |
#include <stdio.h>
long long k, a, n, ok, x;
int main()
{
freopen("inversmodular.in", "r", stdin);
freopen("inversmodular.out","w",stdout);
scanf("%lld %lld ", &a, &n);
ok = 0;
for (k=0; (k*n+1) < a; ++k);
while (!ok)
{
if ( ((k*n)+1) % a == 0)
{
ok = 1;
x = ((k*n)+1)/a;
}
++k;
}
printf("%lld\n", x);
return 0;
}