Pagini recente » Cod sursa (job #1639832) | Cod sursa (job #752979) | Cod sursa (job #3282073) | Cod sursa (job #1752232) | 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;
}