Pagini recente » Cod sursa (job #163915) | OKRs 2008Q4 | Cod sursa (job #1119469) | Cod sursa (job #763607) | Cod sursa (job #2461497)
#include <fstream>
#include <iostream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int t;
int euclidExtins(int a, int b, int &x, int &y)
{
if(!b)
{ x = 1;
y = 0;
return a;
}
int d, x0, y0;
d = euclidExtins(b, a%b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main()
{
f >> t;
while(t--)
{ int a, b, c;
f >> a >> b >> c;
int d, x, y;
d = euclidExtins(a, b, x, y);
if(c % d) g << 0 << ' '<< 0 << '\n';
else g << x * (c / d) << ' ' << y * (c / d) << '\n';
}
return 0;
}