Cod sursa(job #2902131)
Utilizator | Dirirczi Zsolt zsoltzsolt | Data | 15 mai 2022 18:33:10 |
---|---|---|---|
Problema | Algoritmul lui Euclid extins | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.6 kb |
#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;;
}