Cod sursa(job #3194851)
Utilizator | Data | 19 ianuarie 2024 16:25:10 | |
---|---|---|---|
Problema | Invers modular | Scor | 50 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <fstream>
using namespace std;
ifstream fin ("inversmodular.in");
ofstream fout ("inversmodular.out");
int x,y,x0,y0,a,n;
void euclid_extins (int a,int b)
{
if (b==0)
{
x=x0=1;
y=y0=0;
}
else
{
euclid_extins (b,a%b);
x=y0;
y=x0-(a/b)*y0;
x0=x;
y0=y;
}
}
int main ()
{
fin>>a>>n;
euclid_extins (a,n);
fout<<x;
return 0;
}