#ifndef REAL_H
#define REAL_H
#include <utility>
typedef double Real;
const Real precision = 1e-10;
const Real differential = 0.05;
const Real pi = 3.1415926535897932384626433;
inline bool equal(const Real &a, const Real &b, const Real &precision)
{ return (a < b ? b - a : a - b) < precision; }
inline bool equal(const Real &a, const Real &b)
{ return equal(a, b, precision); }
inline bool less(const Real &a, const Real &b)
{ return !equal(a, b) && a < b; }
inline bool greater(const Real &a, const Real &b)
{ return less(b, a); }
inline bool lesseq(const Real &a, const Real &b)
{ return !less(b, a); }
inline bool greatereq(const Real &a, const Real &b)
{ return lesseq(b, a); }
template<typename T>
bool sort(T &a, T &b) {
if (!(a < b)) { std::swap(a, b); return true; }
return false;
}
template<typename T>
bool sort(T &a, T &b, T &c) {
bool x = false;
if (sort(a, b)) x = true;
if (sort(b, c)) x = true;
if (x) sort(a, b);
return x;
}
template<typename T>
T merge(const Real &l, T &a, T &b)
{ return a*(1 - l) + b*l; }
inline Real sign(const Real &x)
{ return equal(x, 0) ? 0 : x < 0 ? -1 : 1; }
inline Real clamp(const Real &x, const Real &min, const Real &max)
{ return x < min ? min : (max < x ? max : x); }
int solve_equation(Real *roots, const Real &k0, const Real &k1);
int solve_equation(Real *roots, const Real &k0, const Real &k1, const Real &k2);
int solve_equation(Real *roots, const Real &k0, const Real &k1, const Real &k2, const Real &k3);
#endif