Pagini recente » Cod sursa (job #1355965) | Cod sursa (job #1005755) | Cod sursa (job #2118302) | Monitorul de evaluare | Cod sursa (job #3323131)
#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;
if(-2000000000<=x&&x<=2000000000&&-2000000000<=y&&y<=2000000000)
fout << x << ' ' << y << '\n';
}
}
return 0;
}