Pagini recente » Cod sursa (job #2390567) | Cod sursa (job #2645266) | Cod sursa (job #2507572) | Cod sursa (job #227753) | Cod sursa (job #2905861)
#include <bits/stdc++.h>
using namespace std;
ifstream f("inversmodular.in");
ofstream g("inversmodular.out");
int euclid_extins(int &x, int &y, int a, int b){
if(b == 0){
x = 1;
y = 0;
return a;
}
else{
int x1 , y1;
int t = euclid_extins(x1, y1, b, a%b);
x = y1;
y = x1 - y1 * (a / b);
return t;
}
}
int main(void){
int a, n;
f >> a >> n;
int x = 0, y = 0;
euclid_extins(x, y, a, n);
g << x;
return 0;
}