浮点数二分
bool check(double x) {}
double bsearch_3(double l, double r)
{
const double eps = 1e-6;
while (r - l > eps)
{
double mid = (l + r) / 2;
if (check(mid)) r = mid;
else l = mid;
}
return l;
}
#include <bits/stdc++.h>
using namespace std;
int main() {
double x;
cin>>x;
double l=-1e4,r=1e4;
while(r-l>1e-8){
double mid=(l+r)/2;
if(mid*mid*mid>=x) r=mid;
else l=mid;
}
printf("%lf\n",l);
cout<<"------------------------"<<endl;
double l1=0,r1=x;
while(r1-l1>1e-8){
double midd=(l1+r1)/2;
if(midd*midd>=x) r1=midd;
else l1=midd;
}
printf("%lf\n",l1);
return 0;
}