Cod sursa(job #1463386)
| Utilizator | Data | 20 iulie 2015 20:36:57 | |
|---|---|---|---|
| Problema | Algoritmul lui Euclid extins | Scor | 50 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.5 kb |
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
int t,a,b,x,y,c;
int _gcd_Extended(int a,int b){
if (b==0) {
x = 1;
y = 0;
return a;
}
int next = _gcd_Extended(b,a%b);
int aux = x;
x = y;
y = aux - (a/b)*y;
return next;
}
int main(void) {
cin>>t;
while(t--){
cin>>a>>b>>c;
int gcd = _gcd_Extended(a,b);
if (c%gcd==0){
cout<<x*c/gcd<<" "<<y*c/gcd<<"\n";
}
else cout<<"0 0\n";
}
return 0;
}
