Pagini recente » Cod sursa (job #3289779) | Cod sursa (job #3123015) | Cod sursa (job #2761294) | Cod sursa (job #2725815) | Cod sursa (job #3283416)
#include <bits/stdc++.h>
using namespace std;
int t;
int gcd(int a, int b, int &x, int &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
int x1, y1;
int d = gcd(b, a % b, x1, y1);
x = y1;
y = x1 - y1 * (a / b);
return d;
}
int main() {
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
cin >> t;
while (t--) {
int a, b, c;
cin >> a >> b >> c;
int x, y;
int d = gcd(a, b, x, y);
if (c % d != 0) {
cout << "0 0";
} else {
cout << x * (c / d) << " " << y * (c / d) << "\n";
}
}
}