Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. #include <string>
  3.  
  4. using namespace std;
  5. double bin_search(double n,double l,double r){
  6.     double mid=(l+r)/2;
  7.     double ans=(mid*mid)+sqrt(mid);
  8.     if((r-l)<(0.0000001)){
  9.         return r;
  10.     }
  11.     if(ans>=n){
  12.         return bin_search(n,l,mid);
  13.     }
  14.     else{
  15.         return bin_search(n,mid+0.0000001,r);
  16.     }
  17. }
  18.  
  19. int main()
  20. {
  21.     double n,b;
  22.     cin>>n;
  23.     double ans=bin_search(n,0,10000);
  24.     cout<<ans;
  25.        return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement