Pagini recente » Cod sursa (job #1711095) | Cod sursa (job #2076015) | Cod sursa (job #2174306) | Cod sursa (job #522564) | Cod sursa (job #3226744)
#include <fstream>
using namespace std;
ifstream cin ("euclid3.in");
ofstream cout ("euclid3.out");
void euclid_extins (int a, int b, int &d, int &x, int &y)
{
if (!b)
{
d = a;
x = 1;
y = 0;
return;
}
int x1, y1;
euclid_extins (b, a % b, d, x1, y1);
x = y1;
y = x1 - (a / b) * y1;
}
int a, b, c, t;
void solve ()
{
cin >> a >> b >> c;
int x, y, d;
x = y = d = 0;
euclid_extins (a, b, d, x, y);
if ((c % d) != 0)
cout << "0 0\n";
else
cout << x * (c / d) << ' ' << y * (c / d) << '\n';
}
int main()
{
ios_base :: sync_with_stdio(false);
cin.tie(0);
for (cin >> t; t--; solve());
return 0;
}