Pagini recente » Clasament cni_preoji | Cod sursa (job #3212604) | Cod sursa (job #2253256) | Cod sursa (job #3267815) | Cod sursa (job #3185811)
#include <bits/stdc++.h>
using namespace std;
long long euclid(long long a, long long b, long long &x, long long &y)
{
if (b == 0)
{
x = 1;
y = 0;
return a;
}
else
{
long long x0, y0, d = euclid(b, a % b, x0, y0);
x = y0;
y = x0 - a / b * y0;
return d;
}
}
signed main()
{
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int t;
fin >> t;
while (t--)
{
long long a, b, c;
fin >> a >> b >> c;
long long x, y, d = euclid(a, b, x, y);
if (c % d)
{
fout << "0 0\n";
}
else
{
fout << x * c / d << ' ' << y * c / d << '\n';
}
}
return 0;
}