Pagini recente » Cod sursa (job #2500568) | Cod sursa (job #1282292) | Cod sursa (job #251138) | Cod sursa (job #1475448) | Cod sursa (job #1475415)
#include <cstdio>
int tests, a, b, c;
int gcdExtended(int a, int b, long long& x, long long& y) {
if (b == 0) {
x = 1; y = 0;
return a;
}
long long x1, y1;
int d = gcdExtended(b, a % b, x1, y1);
x = y1;
y = -a / b * y1 + x1;
return d;
}
int main() {
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
scanf("%d", &tests);
while (tests--) {
scanf("%d%d%d", &a, &b, &c);
long long x, y;
int d = gcdExtended(a, b, x, y);
if (c % d != 0) {
printf("0 0\n");
} else {
printf("%lld %lld\n", x * c / d, y * c / d);
}
}
return 0;
}