Cod sursa(job #2902132)
| Utilizator | Data | 15 mai 2022 18:34:06 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 0 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.59 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.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;;
}