text: a) return (x2 + MOD) % MOD; DEC(x1, pdt(q, x2)); q = b / a, b %= a; if (!b) return (x1 + MOD) % MOD; DEC(x2, pdt(q, x1)); } } inline void DIA(int &a, int b) { MUL(a, _I(b)); } inline int qtt(int a, int b) { return pdt(a, _I(b)); } inline int phi(int n) { int res = n; for (int i = 2; sqr(i) <= n; ++i) if (!(n % i)) { DEC(res, qtt(res, i)); do { n /= i; } while (!(n % i)); } if (n != 1) DEC(res, qtt(res, n)); return res; } struct Po; struct Line; struct Seg; inline int sgn(double x) { return x < -EPS ?-1 : x > EPS; } inline int sgn(double x, double y) { return sgn(x - y); } struct Po { double x, y; Po(double _x = 0, double _y = 0) : x(_x), y(_y) {} friend istream &operator>>(istream &in, Po &p) { return in >> p.x >> p.y; } friend ostream &operator<<(ostream &out, Po p) { return out << "(" << p.x << ", " << p.y << ")"; } friend bool operator==(Po, Po); friend bool operator!=(Po, Po); friend Po operator+(Po, Po); friend Po operator-(Po, Po); friend Po operator*(Po, double); friend Po operator/(Po, double); bool operator<(const Po &rhs) const { return sgn(x, rhs.x) < 0 || sgn(x, rhs.x) == 0 && sgn(y, rhs.y) < 0; } Po operator-() const { return Po(-x, -y); } Po &operator+=(Po rhs) { x += rhs.x, y += rhs.y; return *this; } Po &operator-=(Po rhs) { x -= rhs.x, y -= rhs.y; return *this; } Po &operator*=(double k) { x *= k, y *= k; return *this; } Po &operator/=(double k) { x /= k, y /= k; return *this; } double length_sqr() const { return sqr(x) + sqr(y); } double length() const { return sqrt(length_sqr()); } Po unit() const { return (*this) / length(); } bool dgt() const { return !sgn(x) && !sgn(y); } double atan() const { return atan2(y, x); } void input() { scanf("%lf %lf", &x, &y); } }; bool operator==(Po a, Po b) { return sgn(a.x - b.x) == 0 && sgn(a.y - b.y) == 0; } bool operator!=(Po a, Po b) { return sgn(a.x - b.x) != 0 || sgn(a.y - b.y) != 0; } Po operator+(Po a, Po b) { return Po(a.x + b.x, a.y + b.y); } Po operator-(Po a, Po b) { return Po(a.x - b.x, a.y - b.