Pagini recente » Istoria paginii preoni-2007/runda-finala/poze/evaluare | Cod sursa (job #1847510) | Borderou de evaluare (job #2236161) | Cod sursa (job #886682) | Cod sursa (job #1006135)
#include <stdio.h>
int gcd(int a, int &x, int b, int &y) {
if (b == 0) {
x = 1; y = 0;
return a;
}
int x0, y0;
int d = gcd(b, x0, a % b, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main() {
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int T;
scanf("%d", &T);
for (int test = 1; test <= T; ++test) {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int x, y, d = gcd(a, x, b, y);
if (c % d)
printf("0 0\n");
else
printf("%d %d\n", x * (c / d), y * (c / d));
}
return 0;
}