Pagini recente » Cod sursa (job #3241221) | Cod sursa (job #2350919) | Cod sursa (job #1499119) | Cod sursa (job #2511473) | Cod sursa (job #3183267)
#include <fstream>
using namespace std;
ifstream fin("inversmodular.in");
ofstream fout("inversmodular.out");
void gcd(long long a, long long b, long long& x, long long& y)
{
if(!b)
{
x=1, y=0;
return;
}
else {
long long xx, yy;
gcd(b, a%b, xx, yy);
x=yy;
y=xx-(a/b)*yy;
}
}
long long a, n, rez, y;
int main()
{
ios_base::sync_with_stdio(false);
fin.tie(0);
fin>>a>>n;
fin.close();
gcd(a, n, rez, y);
fout<<rez;
fout.close();
return 0;
}