Pagini recente » Cod sursa (job #2473779) | Cod sursa (job #1297837) | Cod sursa (job #2133246) | Cod sursa (job #1641633) | Cod sursa (job #2821549)
#pragma region
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
#pragma endregion
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;
}
void solve() {
int a, b, c; fin >> a >> b >> c;
int x, y, d = gcd(a, b, x, y);
//cout << x << ' ' << y << '\n';
if (c % d)
fout << "0 0\n";
else
fout << x * (c / d) << ' ' << y * (c / d) << '\n';
}
int main() {
ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1; fin >> t;
while (t--) {
solve();
}
return 0;
}