Pagini recente » Cod sursa (job #721574) | Istoria paginii runda/acs_pc_2017-2018_winter_break_12314132/clasament | Cod sursa (job #721146) | Cod sursa (job #1531276) | Cod sursa (job #589845)
Cod sursa(job #589845)
#include <cstdlib>
#include <cstdio>
using namespace std;
int T, a, b, c, d, x, y;
int gcd(int a, int b, int& x, int& y) {
if (!b) {
x = 1;
y = 0;
return a;
}
int xx, yy;
int d = gcd(b, a % b, xx, yy);
x = yy;
y = xx - (a / b) * yy;
return d;
}
int main() {
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
scanf("%d", &T);
while (T--) {
scanf("%d %d %d", &a, &b, &c);
d = gcd(a, b, x, y);
if (c % d) {
puts("0 0");
} else {
printf("%d %d\n", x * (c / d), y * (c / d));
}
}
fclose(stdout);
fclose(stdin);
return 0;
}