Pagini recente » Cod sursa (job #581518) | Cod sursa (job #1502756) | Cod sursa (job #1757149) | Cod sursa (job #398298) | Cod sursa (job #3314235)
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("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;
f >> T;
while (T--)
{
long long a, b, c, d, x, y;
f >> a >> b >> c;
EuclidExtins(a, b, d, x, y);
if (c % d != 0)
g << "0 0\n";
else
g << x * (c / d) << ' ' << y * (c / d) << '\n';
}
f.close();
g.close();
return 0;
}