#include #define DEBUGe #define NOP do{}while(0) #ifdef DEBUG #define TRACE(...) do{printf(__VA_ARGS__);fflush(stdout);}while(0) #define TRACECR do{printf("\n");fflush(stdout);}while(0) #else #define TRACE(...) NOP #define TRACECR NOP #endif #define REP(a,b) for(int a=0;a<(b);++a) int main( void ) { int aa,bb,cc,dd,pp,qq; int minval = 32767; int maxval = -32768; double x; double val; int maxidx = 0; int minidx = 0; scanf("%d %d %d %d %d %d", &aa, &bb, &cc, &dd, &pp, &qq ); for(int i = pp; i <= qq ; i++) { x = (double)i; val = (double)dd + (double)cc * x; x *= i; val += (double)bb * x; x *= i; val += (double)aa * x; if( val > maxval ) { maxval = val; maxidx = i; } if( val < minval ) { minval = val; minidx = i; } } printf("%d %d %d %d\n", maxval, maxidx, minval, minidx ); return 0; }