Pagini recente » Cod sursa (job #558895) | Cod sursa (job #653455) | Cod sursa (job #1583369) | Cod sursa (job #411916) | Cod sursa (job #1463386)
#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;
}