Pagini recente » Cod sursa (job #2721357) | Cod sursa (job #3244968) | Cod sursa (job #3252800) | Cod sursa (job #2238811) | Cod sursa (job #2873550)
#include <bits/stdc++.h>
#define LL long long
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
pair<LL, LL> euclid(LL a, LL b, LL &d) {
if (b == 0) {
d = a;
return {1, 0};
}
auto p = euclid(b, a % b, d);
return {p.second, p.first - (a / b) * p.second};
}
int main() {
int t;
fin >> t;
for (int i = 0; i < t; i++) {
LL a, b, c, d;
fin >> a >> b >> c;
auto res = euclid(a, b, d);
if (c % d)
fout << 0 << ' ' << 0 << '\n';
else
fout << res.first * (c / d) << ' ' << res.second * (c / d) << '\n';
}
return 0;
}