Pagini recente » Cod sursa (job #3236880) | Cod sursa (job #2084153) | Cod sursa (job #3148969) | Cod sursa (job #2740730) | Cod sursa (job #1088627)
#include <fstream>
using namespace std;
ifstream fi("euclid3.in");
ofstream fo("euclid3.out");
int T,i,a,b,c,d,x,y;
void ee(int a, int b, int &d, int &x, int &y)
{
int xp,yp;
if (b==0){d=a;x=1;y=0;}
else
{
ee(b,a%b,d,xp,yp);
x=yp;
y=xp-a/b*yp;
}
}
int main()
{
fi>>T;
for(i=1;i<=T;i++)
{
fi>>a>>b>>c;
ee(a,b,d,x,y);
if (c%d!=0) fo<<"0 0\n";
else fo<<x*(c/d)<<" "<<y*(c/d)<<"\n";
}
fi.close();
fo.close();
return 0;
}