Pagini recente » Cod sursa (job #1905205) | Cod sursa (job #86277) | Cod sursa (job #3257421) | Cod sursa (job #362859) | Cod sursa (job #1599597)
#include <cstdio>
#include <iostream>
using namespace std;
int euclid(long a, long b, long &x, long &y)
{
if(b==0)
{
x=1;
y=0;
return a;
}
else
{
long x0=0,y0=0,d;
d=euclid(b, a%b, x0, y0);
x=y0;
y=x0-(a/b) *y0;
return d;
}
}
int main()
{
freopen ("euclid3.in", "r", stdin);
freopen ("euclid3.out", "w", stdout);
int T,i,k;
long a, b, c, x=0, y=0, d=0;
cin>>T;
for(i=1;i<=T;i++)
{
cin>>a>>b>>c;
k=0;
d=euclid(a, b, x, y);
if(c% d!=0)
cout<<"0 0"<<'\n';
else
cout<<x*(c/d)<<" "<<y*(c/d)<<'\n';
}
return 0;
}