Pagini recente » Cod sursa (job #418690) | Cod sursa (job #1465471) | Cod sursa (job #672159) | Cod sursa (job #1224778) | Cod sursa (job #2787121)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void GCD(int a, int b, int& d, int& x, int& y)
{
if (!b)
{
d = a;
return;
}
GCD(b, a % b, d, x, y);
int cx = x;
x = y;
y = cx - (a / b) * x;
}
int main()
{
int T; fin >> T;
for (int i = 1, a, b, c, d, x = 1, y = 0; i <= T; ++i)
{
fin >> a >> b >> c;
GCD(a, b, d, x, y);
if (c % d) fout << '0 0\n';
else fout << x * (c / d) << ' ' << y * (c / d) << '\n';
}
return 0;
}