HDU 5105 Math problem

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.