Pagini recente » Cod sursa (job #1440587) | Cod sursa (job #423694) | Cod sursa (job #2171359) | Cod sursa (job #1550227) | Cod sursa (job #2651220)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
ll d;
pair<ll, ll> gg(ll a, ll b)
{
if (b == 0)
{
d = a;
return {1, 0};
}
else
{
pair<ll, ll> it = gg(b, a % b);
return {it.second, it.first - (a / b) * it.second};
}
}
pair<ll, ll> cf(ll a, ll b, ll c)
{
pair<ll, ll> it = gg(a, b);
if (c % d)
{
return {0, 0};
}
it.first *= (c / d);
it.second *= (c / d);
return it;
}
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
freopen ("euclid3.in", "r", stdin);
freopen ("euclid3.out", "w", stdout);
int t;
cin >> t;
while (t--)
{
ll a, b, c;
cin >> a >> b >> c;
pair<ll, ll> it = cf(a, b, c);
cout << it.first << " " << it.second << "\n";
}
}