C++
$\color{#cc33ff}{— > 算法基础课题解}$
$\color{gold}{— > 蓝桥杯辅导课题解}$
思路:
浮点数二分
$\color{#ff00ff}{图解:}$
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int main() {
double x; cin >> x;
double l = -10000, r = 10000;
while (r - l > 1e-8) {
double mid = (l + r) / 2;
if (mid * mid * mid >= x) r = mid;
else l = mid;
}
printf("%lf", l);
return 0;
}
orz