Pagini recente » Cod sursa (job #3168847) | Cod sursa (job #2802401) | Cod sursa (job #2469127) | Cod sursa (job #2938964) | Cod sursa (job #2215923)
#include <bits/stdc++.h>
using namespace std;
void euclidExtins (long long a, long long b, long long &x, long long &y, long long &d) {
if (b == 0) {
x = 1;
y = 0;
d = a;
return ;
}
euclidExtins(b, a % b, x, y, d);
long long newX = y;
long long newY = x - y * (a / b);
x = newX;
y = newY;
}
int main()
{
freopen ("euclid3.in", "r", stdin);
freopen ("euclid3.out", "w", stdout);
int n;
cin >> n;
for (int i = 1; i <= n; ++i) {
long long a, b, c, x, y, d;
cin >> a >> b >> c;
euclidExtins(a, b, x, y, d);
if (c % d) {
cout << "0 0\n";
}
else {
cout << x * (c / d) << ' ' << y * (c / d) << '\n';
}
}
return 0;
}