mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 20:48:48 +00:00
790. 数的三次方根
https://www.acwing.com/problem/content/submission/code_detail/6595736/
This commit is contained in:
parent
86a2d782d6
commit
1ac51c9103
21
AcWing/790/790.cpp
Normal file
21
AcWing/790/790.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
double n, l, r;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
cin >> n;
|
||||||
|
l = -100.00;
|
||||||
|
r = 100.00;
|
||||||
|
while (r - l > 1e-8) {
|
||||||
|
double mid = (l + r) / 2;
|
||||||
|
if (mid * mid * mid >= n) {
|
||||||
|
r = mid;
|
||||||
|
} else {
|
||||||
|
l = mid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cout << fixed << setprecision(6) << l << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user