Pagini recente » Cod sursa (job #1121601) | Cod sursa (job #1892195) | Cod sursa (job #1611786) | Cod sursa (job #391412) | Cod sursa (job #1901855)
#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";
}
}