Pagini recente » Cod sursa (job #180890) | Cod sursa (job #2587568)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("euclid3.in");
ofstream fout ("euclid3.out");
void euclid (int a, int b, int& x, int& y, int& D)
{
if (!b)
{
D = a;
x = 1;
y = 0;
}
else
{
int x0, y0;
euclid (b, a % b, x0, y0, D);
x = y0;
y = (x0 - y0 * (a / b));
}
}
int main ()
{
int t, a, b, c, x, y, D;
fin >> t;
while (t)
{
fin >> a >> b >> c;
euclid (a, b, x, y, D);
if (c % D)
fout << 0 << " " << 0;
else
fout << x * (c / D) << " " << y * (c / D);
fout << "\n";
t--;
}
}