Pagini recente » Cod sursa (job #1767502) | Cod sursa (job #2562291) | Cod sursa (job #783834) | Cod sursa (job #2394155) | Cod sursa (job #3213937)
#include <fstream>
#include <iostream>
#include <string>
#define ll long long
#define ull unsigned long long
#define pii std::pair<int, int>
#define IO (std::string) "euclid3"
std::ifstream cin(IO + ".in");
std::ofstream cout(IO + ".out");
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;
cin >> a >> b >> c;
int x, y, d;
d = gcd(a, b, x, y);
if(c % d == 0){
cout << x * c / d << ' ' << y * c / d << '\n';
}
else cout << 0 << ' ' << 0;
}
int main() {
int t;
cin >> t;
while (t--)
solve();
return 0;
}