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