fork download
  1. // Binary Search » Step 2 » E.Equation
  2. // solution by "for"
  3. #include<bits/stdc++.h>
  4. #define int long long
  5. using namespace std;
  6. signed main(){
  7. ios::sync_with_stdio(false); cin.tie(nullptr);
  8. double n; cin>>n;
  9. double l=0,r=n,mid;
  10. for(int i=0;i<80;i++){
  11. mid=(l+r)/2.0;
  12. if(mid*mid+sqrt(mid)>n) r=mid;
  13. else l=mid;
  14. }
  15. cout<<fixed<<setprecision(12)<<l;
  16. }
  17.  
Success #stdin #stdout 0.01s 5240KB
stdin
Standard input is empty
stdout
0.000000000000