#include #include #include #include #include using namespace std; vector<__int64_t> giveDivisor(const __int64_t c) noexcept { vector<__int64_t> divs; if (c == 0) { return {0}; } const __int64_t abs_c = abs(c); for (__int64_t i = 1; i <= pow(abs_c, 1.0/3.0); ++i) { if (abs_c % i == 0) { divs.push_back(i); divs.push_back(-1*i); divs.push_back(abs_c/i); divs.push_back(-1*(abs_c/i)); } } return divs; } tuple<__int64_t, __int64_t> syntheticDivision(const __int64_t a, const __int64_t b, const __int64_t c, const __int64_t x1) noexcept { return make_tuple(a + x1, b + x1 * (a + x1)); } tuple<__int64_t, __int64_t> solve2d(const __int64_t a, const __int64_t b) noexcept { const __int64_t x2 = (-1 * a + sqrt(a*a - 4*b)) / 2; const __int64_t x3 = (-1 * a - sqrt(a*a - 4*b)) / 2; return make_tuple(x2, x3); } tuple<__int64_t, __int64_t, __int64_t> sort_ans(const __int64_t a, const __int64_t b, const __int64_t c) noexcept { vector<__int64_t> tmp {a, b, c}; sort(tmp.begin(), tmp.end()); return make_tuple(tmp[0], tmp[1], tmp[2]); } tuple<__int64_t, __int64_t, __int64_t> solve3d(const __int64_t a, const __int64_t b, const __int64_t c) noexcept { auto f = [a, b, c](const __int64_t x) { return x*x*x + a*x*x + b*x + c; }; for (const __int64_t x : giveDivisor(c)) { if (f(x) == 0) { const __int64_t x1 = x; __int64_t a2, b2, x2, x3; tie(a2, b2) = syntheticDivision(a, b, c, x1); tie(x2, x3) = solve2d(a2, b2); return sort_ans(x1, x2, x3); } } return make_tuple(0, 0, 0); } int main() { __int64_t a, b, c; cin >> a >> b >> c; __int64_t x1, x2, x3; tie(x1, x2, x3) = solve3d(a, b, c); cout << x1 << " " << x2 << " " << x3 << endl; }