Pagini recente » Cod sursa (job #1494906) | Cod sursa (job #2063690) | Cod sursa (job #2100652) | Cod sursa (job #30421) | Cod sursa (job #2709624)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int t, i, a, b, c, x, y, d;
void euclid(int a, int b, int &x, int &y, int &d)
{
if (b == 0)
{
d = a;
x = 1;
y = 0;
return;
}
int xx, yy, q = a / b;
euclid(b, a % b, xx, yy, d);
x = yy;
y = xx - yy * q;
}
int main()
{
fin >> t;
for (i = 0; i < t; i++)
{
fin >> a >> b >> c;
euclid(a, b, x, y, d);
if (c % d != 0)
fout << "0 0";
else
fout << (c / d) * x << " " << (c / d) * y;
fout << "\n";
}
return 0;
}