#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; int main() { int32_t a, b, c, d, p, q; cin >> a >> b >> c >> d >> p >> q; auto f = [&](int64_t x) { int64_t res = a * x * x * x; res += b * x * x; res += c * x; res += d; return res; }; int32_t mn_i = p, mx_i = p; for (auto i = p + 1; i <= q; ++i) { if (f(i) < f(mn_i)) mn_i = i; if (f(i) > f(mx_i)) mx_i = i; } cout << f(mx_i) << " " << mx_i << " " << f(mn_i) << " " << mn_i << endl; return 0; }