Pagini recente » Cod sursa (job #1584790) | Cod sursa (job #386496) | Cod sursa (job #2413957) | Cod sursa (job #282329) | Cod sursa (job #521507)
Cod sursa(job #521507)
#include <cstdio>
#include <cstring>
int gcd_extended(int a,int b, int *x,int *y)
{
if (b == 0)
{
*x = 1, *y = 0;
return a;
}
else
{
int x0,y0,d;
d = gcd_extended(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;
scanf ("%d",&n);
for (;n;n--)
{
int a,b,c;
scanf ("%d%d%d",&a,&b,&c);
int x,y,d;
d = gcd_extended(a,b,&x,&y);
if (c%d != 0) printf ("0 0\n");
else printf ("%d %d\n",x*(c/d),y*(c/d));
}
}