Pagini recente » Cod sursa (job #2359936) | Cod sursa (job #693874) | Cod sursa (job #117136) | Cod sursa (job #1240376) | Cod sursa (job #2974471)
using namespace std;
#include<iostream>
#include<fstream>
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int n;
long long a,b,c;
long long euclid(long long a, long long b, long long &x, long long &y) {
if (b == 0) {
x = 1;
y = 0;
return a;
}
long long x0, y0, d;
d = euclid(b, a%b, x0, y0);
x = y0;
y = x0-(a/b)*y0;
return d;
}
int main() {
fin >> n;
for (int i = 1; i<=n; i++) {
fin >> a >> b >> c;
long long x, y, d;
d = euclid(a, b, x, y);
if (c%d) {
fout << "0 0\n";
} else {
fout << x*(c/d) << " " << y*(c/d) << "\n";
}
}
return 0;
}