typedef long long ll; typedef long double ld; #include using namespace std; // Union-Find struct UnionFind { // core member vector par; // constructor UnionFind() { } UnionFind(int n) : par(n, -1) { } void init(int n) { par.assign(n, -1); } // core methods int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool same(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x), y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); // merge technique par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } // get groups vector> groups() { vector> member(par.size()); for (int v = 0; v < (int)par.size(); ++v) { member[root(v)].push_back(v); } vector> res; for (int v = 0; v < (int)par.size(); ++v) { if (!member[v].empty()) res.push_back(member[v]); } return res; } // debug friend ostream& operator << (ostream &s, UnionFind uf) { const vector> &gs = uf.groups(); for (const vector &g : gs) { s << "group: "; for (int v : g) s << v << " "; s << endl; } return s; } }; // modint template struct Fp { // inner value long long val; // constructor constexpr Fp() : val(0) { } constexpr Fp(long long v) : val(v % MOD) { if (val < 0) val += MOD; } // getter constexpr long long get() const { return val; } constexpr int get_mod() const { return MOD; } // comparison operators constexpr bool operator == (const Fp &r) const { return this->val == r.val; } constexpr bool operator != (const Fp &r) const { return this->val != r.val; } // arithmetic operators constexpr Fp& operator += (const Fp &r) { val += r.val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp& operator -= (const Fp &r) { val -= r.val; if (val < 0) val += MOD; return *this; } constexpr Fp& operator *= (const Fp &r) { val = val * r.val % MOD; return *this; } constexpr Fp& operator /= (const Fp &r) { long long a = r.val, b = MOD, u = 1, v = 0; while (b) { long long t = a / b; a -= t * b, swap(a, b); u -= t * v, swap(u, v); } val = val * u % MOD; if (val < 0) val += MOD; return *this; } constexpr Fp operator + () const { return Fp(*this); } constexpr Fp operator - () const { return Fp(0) - Fp(*this); } constexpr Fp operator + (const Fp &r) const { return Fp(*this) += r; } constexpr Fp operator - (const Fp &r) const { return Fp(*this) -= r; } constexpr Fp operator * (const Fp &r) const { return Fp(*this) *= r; } constexpr Fp operator / (const Fp &r) const { return Fp(*this) /= r; } // other operators constexpr Fp& operator ++ () { ++val; if (val >= MOD) val -= MOD; return *this; } constexpr Fp& operator -- () { if (val == 0) val += MOD; --val; return *this; } constexpr Fp operator ++ (int) { Fp res = *this; ++*this; return res; } constexpr Fp operator -- (int) { Fp res = *this; --*this; return res; } friend constexpr istream& operator >> (istream &is, Fp &x) { is >> x.val; x.val %= MOD; if (x.val < 0) x.val += MOD; return is; } friend constexpr ostream& operator << (ostream &os, const Fp &x) { return os << x.val; } // other functions constexpr Fp pow(long long n) const { Fp res(1), mul(*this); while (n > 0) { if (n & 1) res *= mul; mul *= mul; n >>= 1; } return res; } constexpr Fp inv() const { Fp res(1), div(*this); return res / div; } friend constexpr Fp pow(const Fp &r, long long n) { return r.pow(n); } friend constexpr Fp inv(const Fp &r) { return r.inv(); } }; struct Eratos { vector primes; vector isprime; vector mebius; vector min_factor; Eratos(int MAX) : primes(), isprime(MAX+1, true), mebius(MAX+1, 1), min_factor(MAX+1, -1) { isprime[0] = isprime[1] = false; min_factor[0] = 0, min_factor[1] = 1; for (int i = 2; i <= MAX; ++i) { if (!isprime[i]) continue; primes.push_back(i); mebius[i] = -1; min_factor[i] = i; for (int j = i*2; j <= MAX; j += i) { isprime[j] = false; if ((j / i) % i == 0) mebius[j] = 0; else mebius[j] = -mebius[j]; if (min_factor[j] == -1) min_factor[j] = i; } } } // prime factorization vector> prime_factors(int n) { vector > res; while (n != 1) { int prime = min_factor[n]; int exp = 0; while (min_factor[n] == prime) { ++exp; n /= prime; } res.push_back(make_pair(prime, exp)); } return res; } // enumerate divisors vector divisors(int n) { vector res({1}); auto pf = prime_factors(n); for (auto p : pf) { int n = (int)res.size(); for (int i = 0; i < n; ++i) { int v = 1; for (int j = 0; j < p.second; ++j) { v *= p.first; res.push_back(res[i] * v); } } } return res; } }; signed main(){ vector c(4); for (int i = 0; i < 4; i++) { std::cin >> c[i]; } ld l,r; std::cin >> l>>r; if(c[3]==0){ if(c[2]==0){ if(c[1]==0){ std::cout << c[0] << std::endl; return 0; } ld x = -c[0]/c[1]; if(l<=x&&x<=r){ std::cout << 0 << std::endl; return 0; } std::cout << min(abs(c[0]+l*c[1]), abs(c[0]+r*c[1])) << std::endl; return 0; } ld x = -1*c[1]/(ld)2/(ld)c[2]; ld ans = 1e18; ans = min({ abs(c[0]+l*c[1]+l*l*c[2]), abs(c[0]+r*c[1]+r*r*c[2]), abs(c[0]+x*c[1]+x*x*c[2]) }); ld x1 = (c[1]+sqrtl(c[1]*c[1]-4*c[2]*c[0]))/(ld)2/c[2]; ld x2 = (c[1]-sqrtl(c[1]*c[1]-4*c[2]*c[0]))/(ld)2/c[2]; if(l<=x1&&x1<=r){ ans = min(ans, abs(c[0]+x1*c[1]+x1*x1*c[2])); } if(l<=x2&&x2<=r){ ans = min(ans, abs(c[0]+x2*c[1]+x2*x2*c[2])); } std::cout << ans << std::endl; return 0; }else{ ld ans = 1e18; ld x1 = (2*c[2]+sqrtl(4*c[2]*c[2]-4*c[3]*c[1]*3))/(ld)2/c[3]/3; ld x2 = (2*c[2]-sqrtl(4*c[2]*c[2]-4*c[3]*c[1]*3))/(ld)2/c[3]/3; ans = min(ans, abs(c[0]+l*c[1]+l*l*c[2]+l*l*l*c[3])); ans = min(ans, abs(c[0]+r*c[1]+r*r*c[2]+r*r*r*c[3])); if(l<=x1&&x1<=r){ ans = min(ans, abs(c[0]+x1*c[1]+x1*x1*c[2]+x1*x1*x1*c[3])); } if(l<=x2&&x2<=r){ ans = min(ans, abs(c[0]+x2*c[1]+x2*x2*c[2]+x2*x2*x2*c[3])); } std::cout<