#include using namespace std; #ifdef LOCAL #include "settings/debug.cpp" #define _GLIBCXX_DEBUG #else #define Debug(...) void(0) #endif #define rep(i, n) for (int i = 0; i < (n); ++i) using ll = long long; using ull = unsigned long long; int main() { int a, b, c, d, p, q; cin >> a >> b >> c >> d >> p >> q; pair maxim = { -1e9, -1e9 }, minim = { 1e9, 1e9 }; for (int x = p; x <= q; x++) { int y = a * x * x * x + b * x * x + c * x + d; if (y > maxim.first) maxim = { y, x }; if (y < minim.first) minim = { y, x }; } printf("%d %d %d %d\n", maxim.first, maxim.second, minim.first, minim.second); return 0; }