mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
Create 1666.cpp
This commit is contained in:
parent
d5e7550c97
commit
a4de87c98e
44
QUSTOJ/1666.cpp
Normal file
44
QUSTOJ/1666.cpp
Normal file
|
@ -0,0 +1,44 @@
|
|||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
|
||||
|
||||
|
||||
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;i<ans;i++)
|
||||
{
|
||||
if(*data[i]>maxvalue) maxvalue=*data[i];
|
||||
}
|
||||
printf("%.5lf\n",maxvalue);
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user