Pagini recente » Cod sursa (job #2624449) | Cod sursa (job #1283118) | Cod sursa (job #2915868) | Cod sursa (job #2367189) | Cod sursa (job #2917136)
#include <stdio.h>
#include <vector>
using namespace std;
int gcd(int a, int b, int &x, int &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
int d, x_0, y_0;
d = gcd(b, a % b, x_0, y_0);
x = y_0;
y = x_0 - (a / b) * y_0;
return d;
}
int main() {
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int t;
scanf("%d", &t);
for (int i = 0; i < t; i++) {
int a, b, c;
scanf("%d %d %d", &a, &b, &c);
int d, x, y;
d = gcd(a, b, x, y);
if (c % d == 0) {
printf("%d %d\n", x *(c / d), y * (c / d));
} else {
printf("0 0\n");
}
}
return 0;
}