Pagini recente » Cod sursa (job #2279029) | Cod sursa (job #2851857) | Cod sursa (job #2679231) | Cod sursa (job #3237795) | Cod sursa (job #2144959)
#include <iostream>
#include <fstream>
using namespace std;
typedef long long int lint;
unsigned short int T, i, j;
lint aa, bb, cc;
lint t1, t2, t3;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
lint ExtendedEuclid(lint a, lint b, lint &x, lint &y) {
if (!b) {
x = 1, y = 0;
return a;
} else {
lint x0, y0, d;
d = ExtendedEuclid(b, a % b, x0, y0);
x = y0;
y = x0 - y0 * (a/b);
return d;
}
}
int main()
{
fin >> T;
for (i = 1; i <= T; i++) {
fin >> aa >> bb >> cc;
t1 = ExtendedEuclid(aa, bb, t2, t3);
if (cc % t1) fout << "0 0\n";
else fout << t2 * (cc / t1) << " " << t3 * (cc / t1) << "\n";
}
return 0;
}