#include using namespace std; #define chmax(a, b) a = (((a)<(b)) ? (b) : (a)) #define chmin(a, b) a = (((a)>(b)) ? (b) : (a)) int main(){ int a, b, c, d, p, q; int maxx = -2000000000, maxy = -2000000000, minx = -2000000000, miny = 2000000000; cin >> a >> b >> c >> d >> p >> q; assert (-1000 <= a && a <= 1000 && -1000 <= b && b <= 1000 && -1000 <= c && c <= 1000 && -1000 <= d && d <= 1000); assert (-100 <= p && p <= q && q <= 100); for (int x = q; p <= x; x--) { int y = a * x * x * x + b * x * x + c * x + d; chmax(maxy, y); chmin(miny, y); if (maxy == y) maxx = x; if (miny == y) minx = x; } cout << maxy << " " << maxx << " " << miny << " " << minx << endl; }