Pagini recente » Cod sursa (job #973765) | Cod sursa (job #2227866) | Cod sursa (job #2214604) | Cod sursa (job #2964156) | Cod sursa (job #967732)
Cod sursa(job #967732)
#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;
long a, b, c, x=0, y=0, d=0;
cin>>T;
for(i=1;i<=T;i++)
{
cin>>a>>b>>c;
if(a<b)
swap(a,b);
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;
}