Pagini recente » Cod sursa (job #581918) | Cod sursa (job #1888190) | Cod sursa (job #216331) | Cod sursa (job #508532) | Cod sursa (job #2488745)
#include <bits/stdc++.h>
void euclid(int &x, int &y, int a, int b) {
int next_gcd, new_x, new_y;
if (b == 0) {
x = 1;
y = 0;
return;
}
euclid(new_x, new_y, b, a % b);
x = new_y;
y = new_x - (a / b) * new_y;
}
int main() {
int a, b, c, n, d, x, y;
// freopen("euclid3.in", "r", stdin);
// freopen("euclid3.out", "w", stdout);
scanf("%d", &n);
while (n --) {
scanf("%d %d %d", &a, &b, &c);
euclid(x, y, a, b);
d = std::__gcd(a, b);
if (c % d == 0) {
printf("%d %d\n", x * (c / d), y * (c / d));
} else {
printf("0 0\n");
}
}
#ifdef LOCAL_DEFINE
std::cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
return 0;
}