Advertisement
welleyth

3968. Square root

Dec 26th, 2020
823
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. #define int long long
  6. #define mp make_pair
  7. #define pb push_back
  8.  
  9. const long double eps = 1e-7;
  10.  
  11. signed main() {
  12.     ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
  13.     //freopen("input.txt","r",stdin);
  14.     //freopen("output.txt","w",stdout);
  15.  
  16.     long double C;
  17.     cin >> C;
  18.  
  19.     long double L = 0,R = (int)1e9;
  20.     long double mid;
  21.  
  22.     while(R-L>eps)
  23.     {
  24.         mid = (L+R)/2;
  25.         if(mid*mid + sqrt(mid) > C)
  26.             R = mid;
  27.         else
  28.             L = mid;
  29.     }
  30.  
  31.     cout << fixed << setprecision(8) << (L+R)/2;
  32.  
  33.     return 0;
  34. }
  35.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement