Pagini recente » Statistici Nichifor Stefana (stefananichifor) | Cod sursa (job #2270164) | Statistici Marcu Beatrice (beatrice_marcu) | Cod sursa (job #1563076) | Cod sursa (job #1463387)
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
long long 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);
long long 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;
}