Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cmath>
- #include <iomanip>
- #include <iostream>
- int main() {
- std::ios_base::sync_with_stdio(false);
- std::cin.tie(nullptr);
- double a;
- std::cin >> a;
- double left = 0.;
- double right = a;
- double DELTA = 0.00000000000001;
- while (right - left > DELTA) {
- double mid = left + (right - left) / 2;
- if (mid * mid - mid + std::sqrt(mid) < a) {
- left = mid;
- } else {
- right = mid;
- }
- }
- std::cout << std::fixed << std::setprecision(6) << (right + left) / 2;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement