Pagini recente » Cod sursa (job #2864139) | Cod sursa (job #2427299) | Cod sursa (job #2720173) | Cod sursa (job #632558) | Cod sursa (job #2928928)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("euclid3.in");
ofstream fout("euclid3.out");
typedef long long ll;
int tt;
inline void euclid(ll a, ll b, ll &d, ll &x, ll &y)
{
if(!b)
{
d = a;
x = 1;
y = 0;
}
else
{
ll x0, y0;
euclid(b, a%b, d, x0, y0);
x = y0;
y = x0 - (a/b)*y0;
}
}
inline void solve()
{
ll a, b, c, d, x, y;
fin >> a >> b >> c;
euclid(a,b,d,x,y);
if(c%d)
{
fout << "0 0\n";
}
else
{
fout << x*(c/d) << ' ' << y*(c/d) << '\n';
}
}
int main()
{
fin >> tt;
while(tt--)
{
solve();
}
}