Cod sursa(job #1364960)
| Utilizator | Data | 27 februarie 2015 22:12:39 | |
|---|---|---|---|
| Problema | Invers modular | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.51 kb |
#include <cstdio>
using namespace std;
void euclid(long long a,long long b, long long &x, long long &y)
{
if(!b){
x = 1;
y = 0;
return;
}
long long x1,y1;
euclid(b,a%b,x1,y1);
x = y1;
y = x1 -(a/b)*y1;
}
int main()
{
freopen("inversmodular.in","r",stdin);
freopen("inversmodular.out","w",stdout);
long long N,M,x,y;
scanf("%lld%lld",&N,&M);
euclid(N,M,x,y);
printf("%lld\n",(x%MOD + MOD) %MOD );
return 0;
}
