Pagini recente » Cod sursa (job #3209788) | Cod sursa (job #2655097) | Cod sursa (job #1478105) | Cod sursa (job #1218088) | Cod sursa (job #2915646)
#include <bits/stdc++.h>
#define vt vector
#define pb push_back
#define em emplace
#define emb emplace_back
using namespace std;
using ll = long long;
using ld = long double;
using ull = unsigned long long;
void re() {
}
void wr() {
}
template <typename fir, typename ...sec> void re(fir &x, sec&... y) {
cin >> x;
re(y...);
}
template <typename fir, typename ...sec> void wr(fir x, sec... y) {
cout << x;
wr(y...);
}
inline void Open(const string Name) {
#ifndef ONLINE_JUDGE
(void)!freopen((Name + ".in").c_str(), "r", stdin);
(void)!freopen((Name + ".out").c_str(), "w", stdout);
#endif
}
void solve() {
int a, b, c; re(a, b, c);
auto egcd = [&](auto&& egcd, int a, int b, int& x, int& y) -> int {
if(b == 0) {
x = 1, y = 0;
return a;
}
int x1, y1;
int d = egcd(egcd, b, a % b, x1, y1);
x = y1;
y = x1 - y1 * (a / b);
return d;
};
int x, y;
int z = egcd(egcd, a, b, x, y);
if(c % z) {
wr("0 0\n");
return;
}
wr(x * (c / z), ' ', y * (c / z), '\n');
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
Open("euclid3");
int t; re(t);
for(;t;t--) {
solve();
}
return 0;
}