Pagini recente » Cod sursa (job #1171212) | Cod sursa (job #1719857) | Cod sursa (job #991757) | Cod sursa (job #1111112) | Cod sursa (job #2964286)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int cmmdc(int a, int b, int& x, int& y)
{
if(!b)
{
x=1, y=0;
return a;
}
int xx, yy, d;
d=cmmdc(b, a%b, xx, yy);
x=yy;
y=xx-(a/b)*yy;
return d;
}
int T;
int main()
{
ios_base::sync_with_stdio(false);
fin.tie(0);
fin>>T;
for(int i=0; i<T; i++)
{
int a, b, c, x, y;
fin>>a>>b>>c;
int d=cmmdc(a, b, x, y);
if(c%d)
fout<<"0 0"<<'\n';
else fout<<x*(c/d)<<' '<<y*(c/d)<<'\n';
}
fin.close();
fout.close();
return 0;
}