Pagini recente » Cod sursa (job #1502476) | Cod sursa (job #627631) | Cod sursa (job #462918) | Cod sursa (job #1357591) | Cod sursa (job #2966048)
#include <fstream>
#include <iostream>
using namespace std ;
int t, a,b, c;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
void euclid(int a, int b, int *d, int *x0, int *y0)
{
if(b == 0)
{
*d = a ;
*x0 = 1;
*y0 = 0;
}
else
{
int x,y;
euclid(b, a%b , d ,&x, &y);
*x0 = y ;
*y0 = x - (a/b) * y ;
}
}
int main()
{
fin >> t;
//cout << d << ' ' << e << ' ' << g ;
for(int i = 0; i<t ; i++)
{
fin >> a>>b>>c;
int d, e,g;
euclid(a,b,&d,&e,&g);
if(c%d != 0) fout << "0 0\n";
else
{
fout << e*(c/d) << " " <<g*(c/d) <<'\n';
}
}
return 0;
}