Pagini recente » Cod sursa (job #794669) | Cod sursa (job #2814958) | Cod sursa (job #2529) | Cod sursa (job #2662804) | Cod sursa (job #3251877)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
#define lint long long
int gcd(lint a,lint b){
while(b){
int r=a%b;
a=b;
b=r;
}
return a;
}
void ee(lint &x,lint &y,lint a,lint b){
if(!b){
x=1;
y=0;
}
else{
ee(x,y,b,a%b);
lint aux=x;
x=y;
y=aux-y*(a/b);
}
}
lint a,b,c,d,t;
int main()
{
fin>>t;
for(int i=1;i<=t;i++){
fin>>a>>b>>c;
lint r1,r2;
ee(r1,r2,a,b);
d=gcd(a,b);
if(c%d==0){
fout<<r1*(c/d)<<' '<<r2*(c/d)<<'\n';
}
else{
fout<<0<<' '<<0<<'\n';
}
}
return 0;
}