Cod sursa(job #282360)
#include <fstream>
#include <algorithm>
using namespace std;
#define FIN "euclid3.in"
#define FOUT "euclid3.out"
void gcd(int a, int b, int &x, int &y, int &d) {
if (b == 0) {
x = 1;
y = 0;
d = a;
return;
}
int x0, y0;
gcd(b, a % b, x0, y0, d);
x = y0;
y = x0 - (a / b) * y0;
}
void solve() {
int T;
for (scanf("%d", &T); T; --T) {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
int x, y, d;
gcd(a, b, x, y, d);
if (c % d) {
printf("0 0\n");
continue;
}
x *= c / d;
y *= c / d;
printf("%d %d\n", x, y);
}
}
int main() {
freopen(FIN, "r", stdin);
freopen(FOUT, "w", stdout);
solve();
return 0;
}