#include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; #define MOD 1000000007 int calc(int a, int b, int c, int d, int x) { int res = a * x * x * x; res += b * x * x; res += c * x; res += d; return res; } int main() { int a, b, c, d, p, q; cin >> a >> b >> c >> d >> p >> q; int mx = calc(a, b, c, d, p); int xmx = p; int mn = calc(a, b, c, d, p); int xmn = p; for (int i = p; i <= q; ++i) { int res = calc(a, b, c, d, i); if (mx < res) { mx = res; xmx = i; } if (res < mn) { mn = res; xmn = i; } } cout << mx << " " << xmx << " " << mn << " " << xmn << endl; return 0; }