Pagini recente » Cod sursa (job #1737179) | Cod sursa (job #261370) | Cod sursa (job #2435002) | Cod sursa (job #354001) | Cod sursa (job #1698991)
#include <iostream>
#include <fstream>
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
inline int euclid(int a, int b, int &x, int &y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
int auxx = 0;
int auxy = 0;
int c = euclid(b, a % b, auxx, auxy);
x = auxy;
y = auxx - a / b * auxy;
return c;
}
int main()
{
int T;
in >> T;
for(int i = 1; i <= T; i++)
{
int a, b, c;
in >> a >> b >> c;
int x = 0;
int y = 0;
int d = euclid(a, b, x, y);
if(c % d != 0)
out << 0 << " " << 0 << "\n";
else
out << c / d * x << " " << c / d * y << "\n";
}
return 0;
}