Pagini recente » Cod sursa (job #3256881) | Cod sursa (job #949395) | Cod sursa (job #1456752) | Cod sursa (job #1082761) | Cod sursa (job #1456386)
# include <bits/stdc++.h>
using namespace std;
# define fi cin
# define fo cout
int gcd(int a,int b,int &x,int &y)
{
if (!a)
{
x = 0;y = 1;
return b;
}
int x1,y1;
int d = gcd(b%a,a,x1,y1);
x = y1 - int(b/a) * x1;
y = x1;
return d;
}
int gcd(int a,int b)
{
return !a ? b:gcd(b%a,a);
}
int main(void)
{
ifstream fi("euclid3.in");
ofstream fo("euclid3.out");
int t;
fi>>t;
while (t --)
{
int a,b,c;
fi>>a>>b>>c;
if (c%gcd(a,b)) fo << "0 0\n";
else
{
int d = gcd(a,b);
a /= d;
b /= d;
int x,y;
d = gcd(a,b,x,y);
x *= c;y *= c;
fo << x << ' ' << y << '\n';
}
}
return 0;
}