Pagini recente » Cod sursa (job #3260861) | Cod sursa (job #1865701) | Cod sursa (job #1399472) | Cod sursa (job #3128779) | Cod sursa (job #1645083)
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int gcd(int a,int b,int &x0,int &y0)
{
if(b==0)
{
x0=1;
y0=0;
return a;
}
else
{
int x,y,d;
d=gcd(b,a%b,x,y);
x0=y;
y0=x-(a/b)*y;
return d;
}
}
int main()
{
int n,a,b,c,d;
int x0,y0;
fin>>n;
while(n--)
{
fin>>a>>b>>c;
x0=y0=0;
d=gcd(a,b,x0,y0);
if(c%d!=0) fout<<"0 0\n";
else
{
fout<<x0*(c/d)<<" "<<y0*(c/d)<<"\n";
}
}
}