Pagini recente » Cod sursa (job #592961) | Cod sursa (job #1624655) | Cod sursa (job #1843082) | Cod sursa (job #792070) | Cod sursa (job #2638212)
#include <fstream>
using namespace std;
ifstream cin("euclid3.in");
ofstream cout("euclid3.out");
long long gcd(long long a, long long b, long long &x, long long &y)
{
if(a % b == 0) {
x = 0, y = 1;
return b;
}
long long d, x0, y0;
d = gcd(b, a % b, x0, y0);
x = y0;
y = x0 - (a / b) * y0;
return d;
}
int main()
{
int T; cin >> T;
while(T--)
{
long long a, b, c, x, y;
cin >> a >> b >> c;
long long d = gcd(a, b, x, y);
if(c % d != 0)
cout << 0 << ' ' << 0 << '\n';
else
cout << x * (c / d) << ' ' << y * (c / d) << '\n';
}
return 0;
}