Pagini recente » Cod sursa (job #1890801) | Borderou de evaluare (job #1754461) | Cod sursa (job #2556419)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
typedef long long mare;
void euclid(int a, int b, mare &x, mare &y, int &d)
{
if (b == 0)
{
d = a;
x = 1;
y = 0;
}
else
{
mare x0, y0;
euclid(b, a%b, x0, y0, d);
x = y0;
y = x0 - a/b*y0;
}
}
int main()
{
int t, i, a, b, c;
int gcd;
mare x, y;
fin >> t;
for (i = 1; i<=t; i++)
{
fin >> a >> b >> c;
euclid(a, b, x, y, gcd);
if (c%gcd == 0)
fout << x * c/gcd << ' ' << y * c/gcd << '\n';
else
fout << "0 0\n";
}
return 0;
}