Pagini recente » Cod sursa (job #2704053) | Cod sursa (job #2437908) | Cod sursa (job #2133350) | Cod sursa (job #2837489) | Cod sursa (job #2572943)
#include <bits/stdc++.h>
using namespace std;
void euclid(int a, int b, int *x, int *y, int *d) {
if (b == 0) {
*d = a;
*x = 1;
*y = 0;
return ;
}
euclid(b, a % b, x, y, d);
int c = a / b;
int x0 = *y;
int y0 = *x - *y * c;
*x = x0;
*y = y0;
}
void solve() {
int a, b, c;
scanf("%d%d%d", &a, &b, &c);
int x, y, d;
euclid(a, b, &x, &y, &d);
if (c % d != 0)
printf("0 0\n");
else
printf("%d %d\n", x * c / d, y * c / d);
}
int main() {
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int t;
scanf("%d", &t);
while (t--)
solve();
return 0;
}