Pagini recente » Cod sursa (job #1629492) | Cod sursa (job #1598156) | Cod sursa (job #2291628) | Cod sursa (job #1488177) | Cod sursa (job #1744885)
#include <stdio.h>
void euclid3(long long a, long long b, long long *d, long long *x, long long *y)
{
if (b == 0)
{
*d = a;
*x = 1;
*y = 0;
}
else
{
long long x0, y0;
euclid3(b, a % b, d, &x0, &y0);
*x = y0;
*y = x0 - (a/b) * y0;
}
}
int main()
{
int n;
long 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("%lld%lld%lld", &a, &b, &c);
euclid3(a, b, &d, &x, &y);
if (c % d) printf("0 0\n");
else printf("%lld %lld\n", x * c/d, y * c/d);
}
return 0;
}