From a4de87c98e1a745a8139c31eccd5558deae687c0 Mon Sep 17 00:00:00 2001 From: Kirito <1362050620@qq.com> Date: Thu, 26 May 2016 07:55:58 +0800 Subject: [PATCH] Create 1666.cpp --- QUSTOJ/1666.cpp | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 QUSTOJ/1666.cpp diff --git a/QUSTOJ/1666.cpp b/QUSTOJ/1666.cpp new file mode 100644 index 0000000..27e2371 --- /dev/null +++ b/QUSTOJ/1666.cpp @@ -0,0 +1,44 @@ +#include +#include +#include +#include + + + +double a,b,c,d,L,R; +double delta; +double x1,x2; + +double fx1,fx2,fL,fR; + +int ans=0; +int i; +double maxvalue=0; + +double* data[4]={&fL,&fR,&fx1,&fx2}; + +int main() +{ + while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&L,&R)==6) + { + ans=2; + delta=b*b-3*a*c; + fL=fabs(a*L*L*L+b*L*L+c*L+d); + fR=fabs(a*R*R*R+b*R*R+c*R+d); + if(delta>0) + { + x1=(-b-sqrt(delta))/(3*a); + x2=(sqrt(delta)-b)/(3*a); + fx1=fabs(a*x1*x1*x1+b*x1*x1+c*x1+d); + fx2=fabs(a*x2*x2*x2+b*x2*x2+c*x2+d); + ans=4; + } + maxvalue=*data[0]; + for(i=1;imaxvalue) maxvalue=*data[i]; + } + printf("%.5lf\n",maxvalue); + } + return 0; +}