#include #include #include #include #include #include #include #include using namespace std; int main() { int a, b, c, d, p, q; cin >> a >> b >> c >> d >> p >> q; long long fx, max1, min1, minx, maxx; for (int i = p; i <= q; i++){ fx = a*i*i*i + b*i*i + c*i + d; if (i == p){ min1 = fx; minx = p; max1 = fx; maxx = p; } if (max1 < fx){ max1 = fx; maxx = i; } if (min1 > fx) { min1 = fx; minx = i; } } cout << max1 << " " << maxx << " " << min1 << " " << minx << endl; }