Pagini recente » Cod sursa (job #1184341) | Cod sursa (job #2948516) | Cod sursa (job #1418988) | Cod sursa (job #3290185) | Cod sursa (job #1699063)
#include <iostream>
#include <cstdio>
using namespace std;
int euclid(int x, int y, int& a, int& b){
if (!y){
a = 1; b = 0;
return x;
}
int d = euclid(y, x % y, b, a);
b -= x / y * a;
return d;
}
int main(){
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int times, x, y, a, b, c, d;
cin >> times;
while (times--){
cin >> x >> y >> c;
d = euclid(x, y, a, b);
if (c % d)
cout << "0 0\n";
else{
c /= d;
cout << a * c << ' ' << b * c << '\n';
}
}
return 0;
}