Pagini recente » Cod sursa (job #1886251) | tema | Cod sursa (job #808804) | Cod sursa (job #1952936) | Cod sursa (job #2024854)
#include <fstream>
int solve_eq(int a, int b, int& x, int& y)
{
if (b == 0) {
x = 1;
y = 0;
return a;
}
int x0, y0;
int d = solve_eq(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main()
{
std::ifstream in{"euclid3.in"};
std::ofstream out{"euclid3.out"};
int a, b, c, T;
for (in >> T; T; --T)
{
in >> a >> b >> c;
int x, y, d;
d = solve_eq (a, b, x, y);
if (c % d) out << "0 0\n";
else out << ((c / d) * x) << ' ' << ( (c/d) * y ) << '\n';
}
return 0;
}