#ifndef ONLINE_JUDGE #define _GLIBCXX_DEBUG #endif #include using namespace std; #define rep(i,n) for(int i=0;i<(n);++i) #define all(a) (a).begin(),(a).end() using ll = long long; int inf = 2e9; ll infLL = 9e18; template istream& operator>>(istream& i,vector& v) {rep(j,v.size()) i>>v[j]; return i;} template void vecout(const vector &v) { rep(i, v.size()) { cout << v[i]; cout << (i == v.size()-1 ? '\n' : ' '); } } // ------------------------------------------------------------------------------------------------ vector c(4); double f(double &x) { return c[0] + c[1] * x + c[2] * (x*x) + c[3] * (x*x*x); } double abs_f_min(vector &c, double &l, double &r) { bool minus = false, plus = false; if(f(l) >= 0 || f(r) >= 0) plus = true; if(f(l) <= 0 || f(r) <= 0) minus = true; if(plus && minus) return 0; double ans; // a = 3 * c[3], b = 2 * c[2], c = c[1] if(c[3] == 0) { if(c[2] == 0) { if(f(l) > 0) { if(c[1] >= 0) ans = abs(f(l)); else ans = abs(f(r)); } else { if(c[1] <= 0) ans = abs(f(l)); else ans = abs(f(r)); } } else { double x = -static_cast(c[1]) / (2 * c[2]); if(l <= x && x <= r) { if(f(x) >= 0) plus = true; if(f(x) <= 0) minus = true; if(plus && minus) return 0; ans = abs(f(x)); } else if(f(l) > 0) { if(2 * c[2] * l + c[1] > 0) ans = abs(f(l)); else ans = abs(f(r)); } else if(f(l) < 0) { if(2 * c[2] * l + c[1] < 0) ans = abs(f(l)); else ans = abs(f(r)); } } return ans; } else { int mid = -2 * c[2]; double D = sqrt(4 * (c[2] * c[2]) - 12 * c[3] * c[1]); double x1 = (mid + D) / (6 * c[3]); double x2 = (mid - D) / (6 * c[3]); ans = numeric_limits::infinity(); bool flag = false; double y; if(l <= x1 && x1 <= r) { y = f(x1); if(y >= 0) plus = true; if(y <= 0) minus = true; ans = min(ans, abs(y)); flag = true; } if(l <= x2 && x2 <= r) { y = f(x2); if(y >= 0) plus = true; if(y <= 0) minus = true; ans = min(ans, abs(y)); flag = true; } if(plus && minus) return 0; else if(flag) return min({ans, abs(f(x1)), abs(f(x2))}); else return min(abs(f(l)), abs(f(r))); } } void solve() { cin >> c; double l, r; cin >> l >> r; cout << abs_f_min(c, l, r) << '\n'; } int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int t = 1; // cin >> t; rep(_,t) solve(); }