Pagini recente » Cod sursa (job #2829732) | Cod sursa (job #2195535) | Cod sursa (job #55733) | Cod sursa (job #2200850) | Cod sursa (job #2277266)
#include <fstream>
#include <iostream>
#include <cstdio>
using namespace std;
ifstream in { "euclid3.in" };
ofstream out { "euclid3.out" };
int Euclid_Extins(int a, int b, int& x, int& y) {
if (!b) {
x = 1;
y = 0;
return a;
}
int x0, y0, d;
d = Euclid_Extins(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main() {
int t; in >> t;
while (t--) {
int a, b, c;
in >> a >> b >> c;
int x, y;
int dc { Euclid_Extins(a, b, x, y) };
if (c % dc)
out << "0 0\n";
else
out << x * (c / dc) << ' ' << y * (c / dc) << '\n';
}
}