- C20250089's blog
P1376 解方程
- 2023-3-8 19:22:46 @
#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;
}