Pagini recente » Rating Brandon Muresan (BrandONN) | Cod sursa (job #3274674) | Cod sursa (job #2450781) | Cod sursa (job #181301) | Cod sursa (job #3197913)
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
int d,x0,y0,x,y,a,b,c,t;
void euclid(int a,int b)
{
if(b==0)
{
d=a;
x=x0=1;
y=y0=0;
}
else
{
euclid(b,a%b);
x=y0;
y=x0-(a/b)*y0;
x0=x;
y0=y;
}
}
int main()
{
cin>>t;
while(t--)
{
cin>>a>>b>>c;
euclid(a,b);
if(c%d!=0)
cout<<0<<" "<<0;
else
cout<<x*(c/d)<<" "<<y*(c/d);
cout<<'\n';
}
return 0;
}