Pagini recente » Cod sursa (job #1132098) | Cod sursa (job #2947657) | Cod sursa (job #2071093) | Cod sursa (job #2924406) | Cod sursa (job #2171606)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int eec(int a, int b, long long &x, long long &y)
{
if (a % b == 0)
{
x = 0;
y = 1;
return b;
}
long long x2;
int cmmdc = eec(b, a % b, x2, x);
y = x2 - x * (a / b);
return cmmdc;
}
int main()
{
int T, a, b, c, d;
long long 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';
}
}