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