Pagini recente » Cod sursa (job #1489417) | Cod sursa (job #2437971) | Cod sursa (job #1291050) | Cod sursa (job #2045890) | Cod sursa (job #2443928)
#include<iostream>
#include<fstream>
using namespace std;
ifstream fin("euclid.in");
ofstream fout("euclid.out");
int gcdex(int a,int b,int &x,int &y) {
if(!b) {
x=1;
y=0;
return a;
}
else {
int d,x1,y1;
d=gcdex(b,a%b,x1,y1);
x=y1;
y=x1-(a/b)*y1;
return d;
}
}
int a,b,c,d,x,y,t;
int main()
{
cin>>t;
while(t--) {
cin>>a>>b>>c;
d=gcdex(a,b,x,y);
if(c%d) cout<<"0 0 \n";
else
cout<<x*(c/d)<<" "<<y*(c/d)<<"\n";
}
}