Pagini recente » Cod sursa (job #2211154) | Cod sursa (job #1587088) | Cod sursa (job #1459626) | Cod sursa (job #2378213) | Cod sursa (job #3235003)
#include <iostream>
using namespace std;
int gcd(int& x, int& y, int a, int b) {
if (b == 0) {
x = 1;
y = 0;
return a;
} else {
int d = gcd(x, y, b, a % b);
int aux = x;
x = y;
y = aux - y * (a / b);
return d;
}
}
int main() {
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int t;
cin >> t;
while(t--) {
int a, b, c;
cin >> a >> b >> c;
int x = 0, y;
int d = gcd(x, y, a, b);
if (c % d == 0) {
cout << x * (c / d) << " " << y * (c / d) << '\n';
} else {
cout << "0 0\n";
}
}
}