Pagini recente » Cod sursa (job #2121924) | Cod sursa (job #1187796) | Cod sursa (job #275314) | Cod sursa (job #1432522) | Cod sursa (job #3253419)
#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;
}