Pagini recente » Diferente pentru utilizator/radugabriel2012 intre reviziile 102 si 83 | Cod sursa (job #366940) | Diferente pentru utilizator/rgrig intre reviziile 12 si 9 | bruh | Cod sursa (job #1170421)
#include <fstream>
using namespace std;
inline long long Cmmdc( long long a, long long b, long long &x, long long &y )
{
long long x0, y0, d;
if (b == 0)
{
x = 1;
y = 0;
return a;
}
d = Cmmdc( b, a % b, x0, y0 );
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main()
{
long long i, nrTeste, a, b, c, d, x, y;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
fin >> nrTeste;
for (i = 1; i <= nrTeste; ++i)
{
fin >> a >> b >> c;
d = Cmmdc(a, b, x, y);
if (c % d != 0)
fout << "0 0\n";
else
{
x = x * c / d;
y = y * c / d;
fout << x << " " << y << "\n";
}
}
return 0;
}