#include #define show(x) cerr << #x << " = " << x << endl using namespace std; using ll = long long; using pii = pair; using vi = vector; template ostream& operator<<(ostream& os, const vector& v) { os << "sz=" << v.size() << "\n["; for (const auto& p : v) { os << p << ","; } os << "]\n"; return os; } template ostream& operator<<(ostream& os, const pair& p) { os << "(" << p.first << "," << p.second << ")"; return os; } constexpr ll MOD = 1e9 + 7; template constexpr T INF = numeric_limits::max() / 100; constexpr ll MAX = (ll)1e9; using P = pair; bool solve(const P& c1, const P& c2, const ll X, const ll Y, P& ans) { const ll XX = c2.second * X - c1.second * Y; const ll YY = -c2.first * X + c1.first * Y; const ll Z = c1.first * c2.second - c1.second * c2.first; if (Z == 0 or XX % Z != 0 or YY % Z != 0) { return false; } else { const ll XXX = XX / Z; const ll YYY = YY / Z; if (XXX > 0 and YYY > 0) { ans = make_pair(XXX, YYY); return true; } else { return false; } } } int main() { cin.tie(0); ios::sync_with_stdio(false); vector

coeff; pair a = make_pair(1, 0); coeff.push_back(a); pair b = make_pair(0, 1); while (b.first + b.second < MAX) { coeff.push_back(b); const auto b_ = make_pair(a.first + b.first, a.second + b.second); a = b; b = b_; } const int size = coeff.size(); const P INFP = make_pair(INF, INF); ll X, Y, Z; cin >> X >> Y >> Z; ll tmp[3] = {X, Y, Z}; sort(tmp, tmp + 3); X = tmp[0]; Y = tmp[1]; Z = tmp[2]; if (X != Y and Y != Z) { P mini = INFP; for (int i = 0; i < size - 2; i++) { for (int j = i + 1; j < size - 1; j++) { P p; if (solve(coeff[i], coeff[j], X, Y, p)) { for (int k = j + 1; k < size; k++) { if (p.first * coeff[k].first + p.second * coeff[k].second == Z) { mini = min(mini, p); } } } } } if (mini != INFP) { cout << mini.first << " " << mini.second << endl; } else { cout << -1 << endl; } } else if (X != Y) { P mini = INFP; for (int i = 0; i < size - 1; i++) { for (int j = i + 1; j < size; j++) { P p; if (solve(coeff[i], coeff[j], X, Y, p)) { mini = min(mini, p); } } } if (mini != INFP) { cout << mini.first << " " << mini.second << endl; } else { cout << -1 << endl; } } else if (Y != Z) { P mini = INFP; for (int i = 0; i < size - 1; i++) { for (int j = i + 1; j < size; j++) { P p; if (solve(coeff[i], coeff[j], Y, Z, p)) { mini = min(mini, p); } } } if (mini != INFP) { cout << mini.first << " " << mini.second << endl; } else { cout << -1 << endl; } } else { if (Z > 1) { bool flag = false; for (int i = size - 1; i >= 0; i--) { if (coeff[i].first + coeff[i].second <= Z and (Z - coeff[i].first) % coeff[i].second == 0) { cout << 1 << " " << (Z - coeff[i].first) / coeff[i].second << endl; flag = true; break; } } if (not flag) { cout << 1 << " " << Z - 1 << endl; } } else { cout << "1 1" << endl; } } return 0; }