注意[0,1], [1,+∞]
#include<iostream>
using namespace std;
int main() {
double x;
cin >> x;
if (x < 0) {
cout << "-";
x = -x;
}
double l, r;
if (x < 1) {
l = x;
r = 1;
}
else {
l = 0;
r = x;
}
while (r - l > 1e-8) {
double mid = l + (r - l) / 2;
if (mid * mid * mid >= x) r = mid;
else l = mid;
}
printf("%.6lf", l);
return 0;
}
$2_1$