Pagini recente » Cod sursa (job #2878012) | Cod sursa (job #516577) | Cod sursa (job #2162658) | Cod sursa (job #905155) | Cod sursa (job #260481)
Cod sursa(job #260481)
#include <stdio.h>
int gcd(int A,int B,int &x,int &y)
{
if (B==0)
{
x=1;
y=0;
return A;
}
int x0,y0,D;
D = gcd(B,A%B,x0,y0);
x = y0;
y = x0-(A/B)*y0;
return D;
}
int main()
{
freopen("euclid3.in","r",stdin);
freopen("euclid3.out","w",stdout);
int n,x,y,C,x0,y0,D;
scanf("%d",&n);
while (n)
{
n--;
scanf("%d%d%d",&x,&y,&C);
D = gcd(x,y,x0,y0);
if (C%D) printf("0 0\n");
else printf("%d %d\n",x0*(C/D),y0*(C/D));
}
}