- C20250089's blog
P1376 解方程
- 2 years ago @
#include<bits/stdc++.h>
using namespace std;
double f(double x,double a,double b){
return x*x+a*x+b;
}
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
double l=c,r=d;
while(r-l>0.00000001){
double m=(l+r)/2;
if(f(l,a,b)*f(m,a,b)<0){
r=m;
}
else{
l=m;
}
}
cout<<fixed<<setprecision(6)<<l;
return 0;
}
By signing up a HFOJ universal account, you can submit code and join discussions in all online judging services provided by us.