Pagini recente » Cod sursa (job #538717) | Cod sursa (job #447362) | Cod sursa (job #3272116) | Cod sursa (job #918407) | Cod sursa (job #2751125)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int gcd(int a, int b, int &x, int &y) {
if(b == 0) {
x = 1;
y = 0;
return a;
}
int x0, y0;
int d = gcd(b, a % b, x0, y0);
x = y0;
y = x0 - y0 * (a / b);
return d;
}
int main() {
int T;
for(fin >> T; T--; ) {
int a, b, c;
fin >> a >> b >> c;
// cout << a << " " << b << " " << c << '\n';
int x, y;
int d = gcd(a, b, x, y);
if(c % d == 0) {
fout << x * (c / d) << " " << y * (c / d) << '\n';
} else {
fout << "0 0\n";
}
}
return 0;
}