Pagini recente » Cod sursa (job #2364773) | Cod sursa (job #1871723) | Rating Cosovan Carmen Adela (CarmenAdela) | Cod sursa (job #131996) | Cod sursa (job #1414362)
#include <bits/stdc++.h>
using namespace std;
void gcd(int a, int b, int &x0, int &y0, int &d)
{
if (!b)
{
x0 = 1;
y0 = 0;
d = a;
}
else
{
int x, y;
gcd(b, a % b, x, y, d);
x0 = y;
y0 = x - (a / b) * y;
}
}
int main()
{
ifstream in("euclid3.in");
ofstream out("euclid3.out");
int T, x, t;
in >> T;
while (T--)
{
int a, b, c, d, x, y;
in >> a >> b >> c;
gcd(a, b, x, y, d);
if (c % d)
out << "0 0\n";
else
out << x * (c / d) << " " << y * (c / d) << "\n";
}
return 0;
}