Pagini recente » Cod sursa (job #1229652) | Cod sursa (job #2331076) | Cod sursa (job #228570) | Cod sursa (job #143064) | Cod sursa (job #3282607)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
long long ext_gcd(long long a, long long b, long long& x, long long& y) {
if (b == 0) {
x = 1, y = 0;
return a;
}
else {
long long nx, ny, g;
g = ext_gcd(b, a % b, nx, ny);
x = ny;
y = nx - (a / b) * x;
return g;
}
}
int main() {
int t;
fin >> t;
while (t--) {
long long a, b, c, x, y;
fin >> a >> b >> c;
long long g = ext_gcd(a, b, x, y);
if (c % g) {
fout << "0 0\n";
}
else {
x *= c / g;
y *= c / g;
fout << x << " " << y << "\n";
}
}
}