Pagini recente » Cod sursa (job #2055078) | Cod sursa (job #252118) | Cod sursa (job #693838) | Cod sursa (job #2357364) | Cod sursa (job #2449192)
#include<iostream>
#include<fstream>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
int euclid(int a, int b, int &x,int &y){
if(b==0){
x=1;
y=0;
return a;
}
else{
int x0, y0,cmmdc;
cmmdc = euclid(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return cmmdc;
}
}
int main(){
int x,y;
int a,b,d,c,nr;
fin>>nr;//nr cazuri
while(nr){
fin>>a>>b>>c;
d=euclid(a,b,x,y);
if(c%d)
{
fout<<0<<" "<<0;
}
else
{
fout<<x*(c/d)<<" "<<y*(c/d);
}
nr--;
}
}