Pagini recente » Cod sursa (job #2915086) | Cod sursa (job #826088) | Cod sursa (job #2533331) | Borderou de evaluare (job #3029845) | Cod sursa (job #2763972)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("euclid3.in");
ofstream fout ("euclid3.out");
void euclid (int a, int b, int &g, long long &x, long long &y)
{
if (b == 0)
{
g = a;
x = 1;
y = 0;
}
else
{
long long x2, y2;
euclid (b, a%b, g, x2, y2);
x = y2;
y = x2 - a/b * y2;
}
}
int main()
{
int t, i, a, b, c, g;
long long x, y;
fin >> t;
for (i = 1; i<=t; i++)
{
fin >> a >> b >> c;
euclid (a, b, g, x, y);
if (c % g != 0)
fout << "0 0\n";
else
fout << x * c / g << ' ' << y * c / g << '\n';
}
return 0;
}