Pagini recente » Cod sursa (job #2272286) | Cod sursa (job #629188) | Cod sursa (job #1969387) | Cod sursa (job #2975094) | Cod sursa (job #1744881)
#include <stdio.h>
void euclid3(long a, long b, long *d, long *x, long *y)
{
if (b == 0)
{
*d = a;
*x = 1;
*y = 0;
}
else
{
long x0, y0;
euclid3(b, a % b, d, &x0, &y0);
*x = y0;
*y = x0 - (a/b) * y0;
}
}
int main()
{
int n;
long a, b, c, x, y, d;
freopen("euclid3.in", "r", stdin);
freopen("euclid3.out", "w", stdout);
scanf("%d", &n);
for (int i = 0; i < n; i++)
{
scanf("%ld%ld%ld", &a, &b, &c);
euclid3(a, b, &d, &x, &y);
if (c % d) printf("0 0\n");
else printf("%ld %ld\n", x * c/d, y * c/d);
}
return 0;
}