Pagini recente » Diferente pentru utilizator/mathboy intre reviziile 84 si 83 | Cod sursa (job #799627) | Cod sursa (job #3250199) | Cod sursa (job #1493695) | 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;
}