Pagini recente » Cod sursa (job #2863979) | Cod sursa (job #2137208) | Cod sursa (job #2836780) | Cod sursa (job #2836951) | Cod sursa (job #1142935)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid(int a, int b, int & d, int & x, int & y)
{
int x0, y0;
if (b == 0)
{
x = 1;
y = 0;
d = a;
}
else
{
euclid(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
int a, b, c, d, x, y;
int t;
fin >> t;
while (t--)
{
fin >> a >> b >> c;
euclid(a, b, d, x, y);
if (c % d == 0)
fout << x * (c /d) << ' ' << y * (c / d);
else
fout << "0 0";
fout << '\n';
}
return 0;
}