Pagini recente » Cod sursa (job #2016982) | Cod sursa (job #312963) | Cod sursa (job #2026231) | Cod sursa (job #1135031) | Cod sursa (job #203951)
Cod sursa(job #203951)
#include <cstdio>
void solve (int a, int b, int c, int &x, int &y)
{
if (b==0)
{
x=c/a;
y=0;
if (((float)c)/a!=x)
x=0;
}
else
{
int temp1, temp2;
solve (b, a%b, c,temp1, temp2);
x=temp2;
y=temp1-(a/b)*temp2;
}
}
int main()
{
int n, a, b, c, x, y;
freopen ("euclid3.in", "r", stdin);
freopen ("euclid3.out", "w", stdout);
scanf ("%d", &n);
for (int i=0; i<n; ++i)
{
scanf ("%d%d%d", &a, &b, &c);
solve (a,b,c,x,y);
printf ("%d %d\n", x, y);
}
fclose(stdin);
fclose(stdout);
return 0;
}