Pagini recente » Cod sursa (job #61006) | Cod sursa (job #2210876) | Cod sursa (job #682046) | Cod sursa (job #2076295) | Cod sursa (job #1657306)
#include <iostream>
#include<fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
inline int gcd(int a, int b, int *x, int *y)
{
if (b == 0)
{
*x = 1;
*y = 0;
return a;
}
else
{
int x0, y0, D;
D=gcd(b, a%b, &x0, &y0);
*x = y0;
*y = x0 - (a / b)*y0;
return D;
}
}
int main()
{
int n,i, A, B, C, x, y, d;
fin >> n;
for (i = 0; i < n; ++i) {
fin >> A >> B >> C;
d = gcd(A, B, &x, &y);
if (C%d != 0)
fout << "0 0\n";
else
fout << x*C / d << " " << y*C / d << "\n";
}
fin.close();
fout.close();
return 0;
}