Pagini recente » Cod sursa (job #3274628) | Cod sursa (job #2954895) | Cod sursa (job #1229384) | Cod sursa (job #3176852) | Cod sursa (job #3251876)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int gcd(int a,int b){
while(b){
int r=a%b;
a=b;
b=r;
}
return a;
}
void ee(int &x,int &y,int a,int b){
if(!b){
x=1;
y=0;
}
else{
ee(x,y,b,a%b);
int aux=x;
x=y;
y=aux-y*a/b;
}
}
int a,b,c,d,t;
int main()
{
fin>>t;
for(int i=1;i<=t;i++){
fin>>a>>b>>c;
int 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;
}