Advertisement
TawratNibir

Untitled

Nov 18th, 2024
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int main() {
  5.     long double x, low, mid, high;
  6.     low = -1;
  7.     high = 5;
  8.     mid = low + (high - low)/2;
  9.     int p = 2000000;
  10.     while(p--) {
  11.         x=mid;
  12.         if((x * x * x) - x - 1 > 0) {
  13.             high = mid;
  14.             mid = low + (high - low)/2;
  15.         }
  16.         else{
  17.             low = mid;
  18.             mid = low + (high - low)/2;
  19.         }
  20.         if(low>high) {
  21.             break;
  22.         }
  23.     }
  24.     cout << fixed << setprecision(70) << x;
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement