Pagini recente » Cod sursa (job #3215578) | Cod sursa (job #3274178) | Cod sursa (job #3276401) | Cod sursa (job #3278361) | Cod sursa (job #3251735)
#include <iostream>
#include <algorithm>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
#define lint int
lint ee(lint &x,lint &y,lint a,lint b){
if(!b){
x=1;
y=0;
return a;
}
else{
lint d=ee(x,y,b,a/b);
lint aux=x;
x=y;
y=aux-y*(a/b);
return d;
}
}
lint ok(lint a,lint b,lint c){
if(__gcd(a,b)==c)
return 1;
return 0;
}
lint t,a,b,c,r,rr;
int main()
{
fin>>t;
while(t){
fin>>a>>b>>c;
lint r1=0,r2=0,d=ee(r1,r2,a,b);
if(c%d){
fout<<r1<<' '<<r2<<'\n';
}
else
fout<<r1*(c/d)<<' '<<r2*(c/d);
t--;
}
return 0;
}