Pagini recente » Cod sursa (job #3286063) | Cod sursa (job #1094408) | Cod sursa (job #1872733) | Cod sursa (job #2869039) | Cod sursa (job #1901824)
#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";
}
}