Pagini recente » Cod sursa (job #2665977) | Cod sursa (job #1867616) | Cod sursa (job #695128) | Cod sursa (job #2062556) | Cod sursa (job #1511455)
#include <stdio.h>
int t, a, b, c;
int extEuclid(int a, int b, int& x, int& y) {
if (!b) {
x = 1;
y = 0;
return a;
}
int x_prec, y_prec, gcd = extEuclid(b, a%b, x_prec, y_prec);
x = y_prec;
y = x_prec - (a / b) * y_prec;
return gcd;
}
int main() {
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int x, y, gcd;
scanf("%d", &t);
while (t--) {
scanf("%d %d %d", &a, &b, &c);
gcd = extEuclid(a, b, x, y);
if (c % gcd)
x = y = 0;
/*else {
x = x * c / gcd;
y = y * c / gcd;
}*/
printf("%d %d\n", x, y);
}
return 0;
}