Pagini recente » Cod sursa (job #1004253) | Cod sursa (job #2694646) | Cod sursa (job #426644) | Cod sursa (job #2859557) | Cod sursa (job #1526952)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fi("euclid3.in");
ofstream fo("euclid3.out");
#define LL long long int
LL x, y, d;
void euclide(LL a, LL b, LL&x, LL&y, LL& d)
{
if (b == 0)
{
x = 1;
y = 0;
d = a;
return;
}
LL x1, y1, q = a / b;
euclide(b, a%b, x1, y1, d);
x = y1;
y = x1 - y1*q;
}
int main()
{
LL a, b, c, t, i;
fi >> t;
for (i = 1; i <= t; i++)
{
fi >> a >> b >> c;
euclide(a, b, x, y, d);
if (c%d == 0)
fo << x*c / d << " " << y*c / d;
else fo << 0 << " " << 0;
fo << "\n";
}
return 0;
}