Pagini recente » Cod sursa (job #1373212) | Cod sursa (job #551270) | Cod sursa (job #900421) | Cod sursa (job #2942032) | Cod sursa (job #1205835)
#include <fstream>
using namespace std;
ifstream f("euclid3.in");
ofstream g("euclid3.out");
int T,a,b,c,d;
int cmmdc(int a,int b,int &x,int &y){
if(b==0){
x=1,y=0;
return a;
}
else{
int xa,ya;
int d=cmmdc(b,a%b,xa,ya);
x=ya;
y=xa-(a/b)*ya;
return d;
}
}
int main(void){
register int i,j,x,y;
f>>T;
for(;T>0;T--){
f>>a>>b>>c;
d=cmmdc(a,b,x,y);
if(c%d!=0)
g<<"0 0\n";
else
g<<x*(c/d)<<" "<<y*(c/d)<<"\n";
}
return 0;
}