Pagini recente » Cod sursa (job #277423) | Cod sursa (job #3186523) | Cod sursa (job #1095013) | Cod sursa (job #1131605) | Cod sursa (job #3127296)
#include <iostream>
#include <fstream>
using namespace std;
using llx = long long;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int euclid_extins(int a, int b, int &x, int &y)
{
if (b == 0)
{
x = 1;
y = 0;
return a;
}
int x0, y0, g;
g = euclid_extins(b, a%b, x0, y0);
x = y0;
y = x0 - 1ll*(a/b)*y0;
return g;
}
int main()
{
int T, a, b, c, x, y, g;
fin >> T;
for (; T; T--)
{
fin >> a >> b >> c;
g = euclid_extins(a, b, x, y);
if (c % g == 0)
fout << c/g * x << ' ' << c/g * y << '\n';
else
fout << 0 << ' ' << 0 << '\n';
}
return 0;
}