Pagini recente » Cod sursa (job #439240) | Cod sursa (job #2385626) | Cod sursa (job #923021) | Cod sursa (job #2850394) | Cod sursa (job #2910655)
#include <bits/stdc++.h>
using namespace std;
int euclid_extins(int a, int b, int &x, int &y) {
if (a==0) {
x = 0;
y = 1;
return b;
}
int x1, y1;
int d = euclid_extins(b%a, a, x1, y1);
x = y1 - (b/a) * x1;
y = x1;
return d;
}
int main()
{
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
int n;
cin >> n;
for (int i=1; i<=n; i++) {
int a, b, c, x, y;
cin >> a >> b >> c;
int d = euclid_extins(a, b, x, y);
if (c%d) {
cout << "0 0\n";
} else {
cout << x * (c / d) << " " << y * (c / d) << '\n';
}
}
return 0;
}