Pagini recente » Cod sursa (job #2362216) | Cod sursa (job #404711) | Cod sursa (job #2275659) | Cod sursa (job #1673516) | Cod sursa (job #2171568)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int eec(int a, int b, int &x, int &y)
{
if (a % b == 0)
{
x = 0;
y = 1;
return b;
}
int x2;
int cmmdc = eec(b, a % b, x2, x);
y = x2 - x * (a / b);
return cmmdc;
}
int main()
{
int T, a, b, c, d, x, y;
fin >> T;
while (T--)
{
bool invers = false;
fin >> a >> b >> c;
d = eec(a, b, x, y);
if (c % d != 0)
{
fout << "0 0\n";
continue;
}
fout << x * c / d << ' ' << y * c / d << '\n';
}
}