Pagini recente » Borderou de evaluare (job #894920) | Borderou de evaluare (job #1330584) | Cod sursa (job #1800471)
#include <bits/stdc++.h>
using namespace std;
int euclid_extended(int a, int b, int& x, int& y) {
if (b == 0) {
x = 1;
y = 0;
return a;
} else {
int x0, y0;
int d = euclid_extended(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
}
int main() {
#ifndef DEBUG
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
#endif
int T; scanf("%d", &T);
for (int tt = 0; tt < T; tt++) {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int x, y;
int ans = euclid_extended(a, b, x, y);
if (c % ans == 0) {
printf("%d %d\n", x * (c / ans), y * (c / ans));
} else {
printf("0 0\n");
}
}
}