Pagini recente » Cod sursa (job #1908451) | Cod sursa (job #1122223) | Cod sursa (job #721365) | Cod sursa (job #770380) | Cod sursa (job #1901859)
#include <fstream>
using namespace std;
void euclid(int a,int b,int &x,int &y,int &d)
{
if (b == 0) {
x = 1, y = 0, d = a;
return;
}
int x0,y0;
euclid(b,a%b,x0,y0,d);
x = y0;
y = x0 - y0 * (a / b);
return;
}
int main()
{
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int T; fin >> T;
while (T--)
{
int a,b,c,d,x,y;
fin >> a >> b >> c;
euclid(a,b,x,y,d);
if (c % d != 0)
fout << "0 0\n";
else fout << x * (c / d) << " " << y * (c / d) << "\n";
}
}