Pagini recente » Cod sursa (job #2785959) | Cod sursa (job #2660698) | Cod sursa (job #2258086) | Cod sursa (job #2258750) | Cod sursa (job #3216104)
#include <bits/stdc++.h>
using namespace std;
ifstream in("euclid3.in");
ofstream out("euclid3.out");
#define pii pair<int, int>
#define pb push_back
#define fi first
#define se second
const int NMAX = 1e5 + 5;
const int INF = 0x3f3f3f3f;
int a, b, c, x, y, d, t;
void read()
{
in >> t;
}
void euclid(int a, int b, int &d, int &x, int &y)
{
if (b == 0)
{
x = 1;
y = 0;
d = a;
return;
}
int x1, y1;
euclid(b, a % b, d, x1, y1);
x = y1;
y = x1 - a / b * y1;
}
void solve()
{
while (t--)
{
in >> a >> b >> c;
euclid(a, b, d, x, y);
//inmultesc cu c/d sa ajung la o ecuatie care da = c
if (c % d == 0)
out << x * (c / d) << ' ' << y * (c / d);
else
out << 0 << ' ' << 0;
out << '\n';
}
}
int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(false);
read();
solve();
return 0;
}