Cod sursa(job #2110512)
| Utilizator | Data | 20 ianuarie 2018 19:08:40 | |
|---|---|---|---|
| Problema | Invers modular | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.47 kb |
#include <fstream>
using namespace std;
ifstream fin("inversmodular.in");
ofstream fout("inversmodular.out");
long long a,n,x,y,d;
void Euclid_extins(long long a, long long b, long long &x, long long &y, long long &d)
{
if(b==0){d=a;x=1;y=0;}
else
{
long long x0,y0;
Euclid_extins(b,a%b,x0,y0,d);
x=y0;
y=x0-a/b*y0;
}
}
int main()
{
fin>>a>>n;
Euclid_extins(n,a,x,y,d);
fout<<y;
return 0;
}
