Pagini recente » Cod sursa (job #2778648) | Cod sursa (job #1185445) | Cod sursa (job #345935) | Cod sursa (job #745731) | Cod sursa (job #2455617)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclidean(long long a, long long b, long long &d, long long &x, long long &y) {
if (!b) {
x = 1;
y = 0;
d = a;
return;
}
euclidean(b, a % b, d, x, y);
long long aux = x;
x = y;
y = aux - (a / b) * y;
}
int main() {
long long n, a, b, c, gcd, x, y;
fin >> n;
for(int i = 0; i < n; ++i) {
fin >> a >> b >> c;
euclidean(a, b, gcd, x, y);
if (c % gcd)
fout << "0 0\n";
else
fout << x * (c / gcd) << " " << y * (c / gcd) << "\n";
}
return 0;
}