Pagini recente » Cod sursa (job #2726479) | Cod sursa (job #1626093) | Cod sursa (job #850305) | Cod sursa (job #1495926) | Cod sursa (job #2434360)
#include <iostream>
#include <fstream>
void euclid(int a, int b, int *d)
{
if (b == 0) {
*d = a;
} else
euclid(b, a % b, d);
}
inline int euclid_extins(int a,int b,int &x, int &y)
{
if(b == 0)
{
x = 1;
y = 0;
return a;
}
else
{
int x0, y0, d;
d = euclid_extins(b,a%b,x0,y0);
x = y0;
y = x0 -(a/b)*y0;
return d;
}
}
int main()
{
std::ifstream fin("euclid3.in");
std::ofstream fout("euclid3.out");
int t;
fin >> t;
for(int i = 1; i <= t; ++i)
{
int a, b,c;
fin >> a >> b >> c;
int x, y,d;
d = euclid_extins(a,b,x,y);
if(c % d)
fout << "0 0\n";
else
{
fout << x *(c/d) << " " << y *(c/d)<< '\n';
}
}
return 0;
}