Advertisement
Derga

Untitled

Aug 5th, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdint>
  3. #include <cstdio>
  4. #include <math.h>
  5.  
  6. using namespace std;
  7.  
  8. int main() {
  9.     long double c;
  10.     cin >> c;
  11.  
  12.     long double L = 0;
  13.     long double R = abs(c);
  14.  
  15.     for (int i = 0; i < 200; ++i) {
  16.         long double mid = L + (R - L) / 2;
  17.         if (mid * mid + sqrt(mid) >= c) {
  18.             R = mid;
  19.         } else {
  20.             L = mid;
  21.         }
  22.     }
  23.  
  24.     cout.precision(6);
  25.     cout << R << endl;
  26.  
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement