Pagini recente » Cod sursa (job #176212) | Cod sursa (job #1064698) | Cod sursa (job #1367386) | Cod sursa (job #2093405) | Cod sursa (job #2587567)
#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)
cout << 0 << " " << 0;
else
cout << x * (c / D) << " " << y * (c / D);
cout << "\n";
t--;
}
}