Cod sursa(job #2673693)
Utilizator | Data | 17 noiembrie 2020 15:59:57 | |
---|---|---|---|
Problema | Invers modular | Scor | 50 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.47 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin("inversmodular.in");
ofstream fout("inversmodular.out");
void cmmdc(int a, int b, int &x, int &y)
{
if(b == 0)
{
x = 1;
y = 0;
}
else
{
int x0,y0;
cmmdc(b, a % b, x0, y0);
x = y0;
y = x0 - a / b * y0;
}
}
int main()
{
int a,n;
int x,y;
fin >> a >> n;
cmmdc(a,n,x,y);
fout << x;
return 0;
}