Pagini recente » Cod sursa (job #3300534) | Cod sursa (job #6437) | Cod sursa (job #304686) | Cod sursa (job #2651731) | Cod sursa (job #806919)
Cod sursa(job #806919)
#include <cstdlib>
#include <fstream>
using namespace std;
inline void gcd(int a, int b, int& x, int& y, int& d)
{
if(0 == b)
{
d = a;
x = 1;
y = 0;
return;
}
int x0, y0;
gcd(b, a%b, x0, y0, d);
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, x, y, d);
if(0 == c%d) out << (c/d)*x << ' ' << (c/d)*y << '\n';
else out << "0 0\n";
}
return EXIT_SUCCESS;
}