Pagini recente » Cod sursa (job #1231589) | Cod sursa (job #1205983) | Cod sursa (job #2569527) | Cod sursa (job #1659209) | Cod sursa (job #2900037)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("inversmodular.in");
ofstream fout("inversmodular.out");
int n, a, b, c;
int gcd(int a, int b, int &x, int &y){
if(b == 0){
x = 1;
y = 0;
return a;
}
else{
int x1 , y1;
int g = gcd(b, a % b, x1, y1);
x = y1;
y = x1 - y1 * (a / b);
return g;
}
}
int main(){
fin >> a >> b;
int x, y;
gcd(a, b, x, y);
fout << x;
}