Pagini recente » Cod sursa (job #1648259) | Cod sursa (job #2039737) | Cod sursa (job #2904531) | Cod sursa (job #1575714) | Cod sursa (job #1527769)
#include <iostream>
#include <cstdio>
using namespace std;
void euclid(int a, int b, int &d, int &x, int &y)
{
if (b == 0) {
d = a;
x = 1;
y = 0;
}
else {
int x0, y0;
euclid(b, a%b, d, x0, y0);
x = y0;
y = x0 - y0*(a/b);
}
}
int main()
{
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int t, a, b, c;
scanf("%d", &t);
for (int i = 1; i <= t; i++) {
scanf("%d %d %d", &a, &b, &c);
int d, x, y;
euclid(a, b, d, x, y);
if (c%d == 0 ) {
printf("%d %d\n", x * (c/d), y * (c/d));
}
else printf("0 0\n");
}
return 0;
}