Pagini recente » Cod sursa (job #43667) | Cod sursa (job #2428285) | Cod sursa (job #2536071) | Cod sursa (job #2880582) | Cod sursa (job #2529941)
#include<bits/stdc++.h>
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
int cmmdc(int a,int b,int&x,int&y){
if(b==0){
x=1;
y=0;
return a;
}
else{
int x0,y0;
int to_return=cmmdc(b,a%b,x0,y0);
x=y0;
y=x0-(a/b)*y0;
return to_return;
}
}
int main(){
int test_count;
in>>test_count;
int a,b,c;
for(int i=0;i<test_count;i++){
in>>a>>b>>c;
int x,y;
int cmd=cmmdc(a,b,x,y);
if(c%cmd!=0){
out<<"0 0"<<'\n';
}
else{
int div=c/cmd;
out<<x*div<<" "<<y*div<<" "<<'\n';
}
}
return 0;
}