Let's beg.F(X)=|A∗X3+b∗ x 2+c ∗x +d | (l≤ x≤ r max
This topic discusses the values of A and B, and if a==0, then the equation becomes a unary two-time equation, which can be directly found in the function values of the endpoint and the symmetric axis (if the axis of symmetry is within a given interval), and if a! = 0, then the derivation, the derivation, the delta of the two-time equation, If the delta is less than or equal to 0, the description is monotonous, then the maximum value is taken at the end point, if the delta is greater than 0, then the value of the two poles (if the poles are within a given interval) and the value of the endpoint values are compared.
/************************************************************************* > File Name:math.cpp ; Author:howe_young > Mail: [email protected] > Created time:2015 September 14 Monday 20:18 44 sec ************************************************************************/#include<cstdio>#include<iostream>#include<cstring>#include<cmath>#include<cstdlib>#include<algorithm>using namespaceStd;typedefLong Longll;DoubleA, B, C, D, L, R;Const DoubleEPS = 1e-8;DoubleFuncDoublex) { returnFabs (A * x * x * x + b * x * x + c * x +d);}intSgnDoublex) { if(Fabs (x) < EPS)return 0; returnX >0?1: -1;}intMain () { while(~SCANF ("%lf%lf%lf%lf%lf%lf", &a, &b, &c, &d, &l, &R)) {DoubleAns =Max (func (L), func (R)); if(A = =0) { if(b! =0) { Doublet =-c/2.0/b; if(SGN (T-L) >0&& SGN (T-r) <0) ans=Max (ans, func (t)); } } Else { DoubleDelta =4* b * B- AAC; if(Delta >0) { DoubleX1 = (-2.0* B-SQRT (Delta))/6.0/A; Doublex2 = (-2.0* b + sqrt (delta))/6.0/A; if(SGN (x1-l) >=0&& sgn (x1-r) <=0) ans=Max (ans, func (x1)); if(SGN (x2-l) >=0&& sgn (x2-r) <=0) ans=Max (ans, func (x2)); }} printf ("%.2lf\n", ans); } return 0;}
HDU 5105 Math problem