Pagini recente » Cod sursa (job #1217978) | Cod sursa (job #2478798) | Cod sursa (job #314360) | Cod sursa (job #1368006) | Cod sursa (job #2570380)
#include <stdio.h>
#include <iostream>
using namespace std;
const int MAXT = 100;
int t;
int a, b, c;
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 - (a / b) * y0;
}
}
int main() {
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
cin >> t;
while (t --) {
cin >> a >> b >> c;
int d, x, y;
euclid(a, b, d, x, y);
x *= c / d;
y *= c / d;
if (c % d) {
cout << 0 << ' ' << 0 << '\n';
}
else {
cout << x << ' ' << y << '\n';
}
}
return 0;
}