You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
438 B

2 years ago
#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
int main() {
double x;
cin >> x;
double l = -10000, r = 10000;
while (r - l > eps) {
double mid = (l + r) / 2; // 注意浮点数这里不能用右移1位
if (mid * mid * mid > x)
r = mid; // mid>x后面没有"="
else
l = mid;
}
printf("%.6lf\n", l);
return 0;
}