Pagini recente » Cod sursa (job #1054741) | Cod sursa (job #2849432) | Cod sursa (job #1840546) | Cod sursa (job #1362569) | Cod sursa (job #2743224)
#include <bits/stdc++.h>
using namespace std;
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
void euclid_extins(int a, int b, long long &x, long long &y)
{
if(a==0)
{
x = 0;
y = 1;
return;
}
long long x0,y0;
euclid_extins(b%a,a,x0,y0);
x = y0-(b/a)*x0;
y = x0;
}
int main()
{
int a,n;
f>>a>>n;
long long x,y;
euclid_extins(a,n,x,y);
g<<x%n<<'\n';
return 0;
}