Pagini recente » Cod sursa (job #940512) | Monitorul de evaluare | Diferente pentru problema/xcopy intre reviziile 6 si 5 | Diferente pentru problema/interclas intre reviziile 6 si 14 | Cod sursa (job #3323128)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void EuclidExtins(long long a, long long b, long long &d, long long &x, long long &y)
{
if(b == 0)
{
x = 1;
y = 0;
d = a;
}
else
{
long long x0, y0;
EuclidExtins(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
int T;
fin >> T;
while(T--)
{
long long a, b, c, d, x, y;
fin >> a >> b >> c;
EuclidExtins(a, b, d, x, y);
if(c % d != 0)
{
fout << 0 << 0 << '\n';
}
else
{
long long k = c / d;
x *= k;
y *= k;
fout << x << ' ' << y << '\n';
}
}
return 0;
}