Cod sursa(job #262898)
| Utilizator | Data | 19 februarie 2009 18:52:18 | |
|---|---|---|---|
| Problema | Invers modular | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <stdlib.h>
#include <stdio.h>
void cmmdc(long long a,long long b,long long &x,long long &y)
{int aux;
if(b==0)
{x=1;
y=0;
}
else
{cmmdc(b,a%b,x,y);
aux=x;
x=y;
y=aux-y*(a/b);
}
}
int main ()
{freopen("inversmodular.in","r",stdin);
freopen("inversmodular.out","w",stdout);
long long a,n,x,y;
scanf("%lld %lld",&a,&n);
cmmdc(a,n,x,y);
if(x>y)
printf("%lld",x);
else
printf("%lld",y);
return 0;
}
