Pagini recente » Cod sursa (job #2046810) | Cod sursa (job #1831686) | Cod sursa (job #2367309) | Cod sursa (job #588014) | Cod sursa (job #3202905)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int xlcd(int a, int b, int& x, int& y) {
if (!b) {
x = 1;
y = 0;
return a;
}
int x0, y0;
int lcd = xlcd(b, a % b, x0, y0);
x = y0;
y = x0 - a / b * x;
return lcd;
}
void solve() {
int a, b, c, x, y;
fin >> a >> b >> c;
int lcd = xlcd(a, b, x, y);
if (c % lcd) {
fout << 0 << ' ' << 0 << '\n';
} else
fout << x * (c / lcd) << ' ' << y * (c / lcd) << '\n';
}
int main() {
int t;
fin >> t;
for (int i = 0; i < t; i++)
solve();
return 0;
}