Pagini recente » Cod sursa (job #38549) | Cod sursa (job #1240085) | Cod sursa (job #1778259) | Cod sursa (job #2218950) | Cod sursa (job #586431)
Cod sursa(job #586431)
#include <stdio.h>
int tests, a, b, c;
int d, x, y;
int euclizi(int a, int b, int &x, int &y )
{
if (b == 0)
{
x = 1;
y = 0;
return a;
}
int x0, y0, d;
d = euclizi(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);
scanf("%d", &tests);
while (tests)
{
scanf("%d %d %d", &a, &b, &c);
d = euclizi(a, b, x, y);
if (c % d)
printf("0 0\n");
else
printf("%d %d\n", x*(c/d), y*(c/d));
tests--;
}
return 0;
}