Pagini recente » Cod sursa (job #1381642) | Cod sursa (job #1696256) | Cod sursa (job #2352632) | Cod sursa (job #1364885) | Cod sursa (job #2873444)
#include <bits/stdc++.h>
#define LL long long
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
LL euclid(LL a, LL b, LL &x, LL &y)
{
if (b == 0) {
x = 1, y = 0;
return a;
}
LL auxx, auxy, res;
res = euclid(b, a % b, auxx, auxy);
x = auxy, y = auxx - (a / b) * auxy;
return res;
}
int main() {
int t;
fin >> t;
for (int i = 0; i < t; i++) {
LL a, b, c, x, y, res;
fin >> a >> b >> c;
res = euclid(a, b, x, y);
if (c % res != 0)
fout << 0 << ' ' << 0 << '\n';
else
fout << x * (c / res) << ' ' << y * (c / res) << '\n';
}
return 0;
}