Pagini recente » Diferente pentru utilizator/robytzza intre reviziile 55 si 23 | Borderou de evaluare (job #295032) | Cod sursa (job #922092)
Cod sursa(job #922092)
#include <cstdlib>
#include <fstream>
using namespace std;
void gcd(int a, int b, int& d, int& x, int& y)
{
if(!b)
{
x = 1;
y = 0;
d = a;
}
else {
int x0, y0;
gcd(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
int T, a, b, c, d, x, y;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
for(in >> T; T; --T)
{
in >> a >> b >> c;
gcd(a, b, d, x, y);
if(c % d) out << "0 0\n";
else out << (x * (c / d)) << ' ' << (y * (c / d)) << '\n';
}
return EXIT_SUCCESS;
}