Pagini recente » Cod sursa (job #1667656) | Cod sursa (job #2316297) | Cod sursa (job #446717) | Cod sursa (job #2543491) | Cod sursa (job #2455155)
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
void euclid(long long int a, long long int b, long long int &d, long long int &x, long long int &y)
{
if (b == 0)
{
d = a;
x = 1;
y = 0;
}
else
{
long long int x0, y0;
euclid(b, a % b, d, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
}
}
int main()
{
unsigned short int T, i;
long long int a, b, c, d, x, y, m, n;
f >> T;
for(i=0; i<T; i++)
{
f >> a >> b >> c;
euclid(a, b, d, x, y);
if(c%d)
g << "0 0" << '\n';
else
{
m=x*(c/d);
n=y*(c/d);
g << m << " " << n << '\n';
}
}
f.close();
g.close();
return 0;
}