Pagini recente » Cod sursa (job #895661) | Cod sursa (job #29789) | Cod sursa (job #1052752) | Cod sursa (job #2750766) | Cod sursa (job #2902131)
#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(){
int a, b, t, c;
f >> a >> b >> c;
int x, y;
t = euclid_extins(x,y,a,b);
if(c%t)
g << "0 0" << endl;
else g << x*(c/t) << ' ' << y*(c/t) << endl;;
}