Pagini recente » Cod sursa (job #2040005) | Cod sursa (job #1923058) | Cod sursa (job #1629831) | Cod sursa (job #1253638) | Cod sursa (job #2026000)
#include <bits/stdc++.h>
int cmmdc(int a,int b,int &x,int &y){
if(!b){
x=1;y=0;
return a;
}
int x1,y1;
int d=cmmdc(b,a%b,x1,y1);
x=y1;
y=x1-a/b*y1;
return d;
}
int main(){
freopen("euclid3.in","r",stdin);
freopen("euclid3.out","w",stdout);
int n;
scanf("%d",&n);
for(int i=1;i<=n;++i){
int a,b,c,x,y;
scanf("%d %d %d",&a,&b,&c);
int d=cmmdc(a,b,x,y);
if(c%d!=0) printf("0 0\n");
else printf("%d %d\n",x*c/d,y*c/d);
}
return 0;
}