Cod sursa(job #3253419)
Utilizator | Data | 2 noiembrie 2024 16:02:45 | |
---|---|---|---|
Problema | Invers modular | Scor | 50 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
#define LL long long
using namespace std;
ifstream f("inversmodular.in"); ofstream g("inversmodular.out");
LL x, y,d,a,b;
void euclid_extins( LL a, LL b, LL &x, LL &y, LL &d)
{ LL xo, yo;
if (b==0){d=a;y=0;x=1;}
else {euclid_extins(b, a%b, xo, yo,d);
x=yo;
y=xo-a/b*yo;
}
}
int main()
{f>>a>>b;euclid_extins(a,b, x,y, d);
g<<x;
return 0;
}