ACW.790数的三次方根
思路
- 依照常规二分查找,寻找不满足条件区间
mid * mid * mid > n
的左端点即可 - 边界条件
while (right - left > 1e-7)
left
和right
不必+1
,而是left = mid; else right = mid
代码
```cppinclude
using namespace std;
const int N = 1e4 + 5;
int main() { double n = 0; cin >> n; double left = -1e4, right = 1e4; while (right - left > 1e-7) { double mid = (left + right) / 2; if (double(mid mid mid) >= n) { right = mid; } else { left = mid; } }
printf("%.6f", left);
return 0;
} ```