結果
問題 | No.1083 余りの余り |
ユーザー | r1933 |
提出日時 | 2021-02-07 17:38:14 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
CE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 21,619 bytes |
コンパイル時間 | 2,402 ms |
コンパイル使用メモリ | 213,816 KB |
最終ジャッジ日時 | 2024-11-15 00:01:01 |
合計ジャッジ時間 | 3,037 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp: In instantiation of 'void input(Head&&, Tail&& ...) [with Head = std::vector<long int>&; Tail = {}]': main.cpp:636:10: required from here main.cpp:33:9: error: no match for 'operator>>' (operand types are 'std::istream' {aka 'std::basic_istream<char>'} and 'std::vector<long int>') 33 | cin >> head; | ~~~~^~~~~~~ In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39, from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54, from main.cpp:2: /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:120:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__istream_type& (*)(__istream_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>]' 120 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ^~~~~~~~ /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:120:36: note: no known conversion for argument 1 from 'std::vector<long int>' to 'std::basic_istream<char>::__istream_type& (*)(std::basic_istream<char>::__istream_type&)' {aka 'std::basic_istream<char>& (*)(std::basic_istream<char>&)'} 120 | operator>>(__istream_type& (*__pf)(__istream_type&)) | ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~ /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:124:7: note: candidate: 'std::basic_istream<_CharT, _Traits>::__istream_type& std::basic_istream<_CharT, _Traits>::operator>>(__ios_type& (*)(__ios_type&)) [with _CharT = char; _Traits = std::char_traits<char>; __istream_type = std::basic_istream<char>; __ios_type = std
ソースコード
#pragma GCC optimize("Ofast") #include "bits/stdc++.h" // Begin Header {{{ using namespace std; #ifndef DEBUG #define dump(...) #endif #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) #define rep(i, b, e) for (intmax_t i = (b), i##_limit = (e); i < i##_limit; ++i) #define repc(i, b, e) for (intmax_t i = (b), i##_limit = (e); i <= i##_limit; ++i) #define repr(i, b, e) for (intmax_t i = (b), i##_limit = (e); i >= i##_limit; --i) #define var(Type, ...) Type __VA_ARGS__; input(__VA_ARGS__) constexpr size_t operator""_zu(unsigned long long value) { return value; }; constexpr intmax_t operator""_jd(unsigned long long value) { return value; }; constexpr uintmax_t operator""_ju(unsigned long long value) { return value; }; constexpr int INF = 0x3f3f3f3f; constexpr intmax_t LINF = 0x3f3f3f3f3f3f3f3f_jd; template <class T, class Compare = less<>> using MaxHeap = priority_queue<T, vector<T>, Compare>; template <class T, class Compare = greater<>> using MinHeap = priority_queue<T, vector<T>, Compare>; inline void input() {} template <class Head, class... Tail> inline void input(Head&& head, Tail&&... tail) { cin >> head; input(forward<Tail>(tail)...); } template <class Container, class Value = typename Container::value_type, enable_if_t<!is_same<Container, string>::value, nullptr_t> = nullptr> inline istream& operator>>(istream &is, Container &vs) { for (auto &v: vs) is >> v; return is; } template <class T, class U> inline istream& operator>>(istream &is, pair<T, U> &p) { is >> p.first >> p.second; return is; } inline void output() { cout << "\n"; } template <class Head, class... Tail> inline void output(Head&& head, Tail&&... tail) { cout << head; if (sizeof...(tail)) cout << " "; output(forward<Tail>(tail)...); } template <class Container, class Value = typename Container::value_type, enable_if_t<!is_same<Container, string>::value, nullptr_t> = nullptr> inline ostream& operator<<(ostream &os, const Container &vs) { static constexpr const char *delim[] = {" ", ""}; for (auto it = begin(vs); it != end(vs); ++it) { os << delim[it == begin(vs)] << *it; } return os; } template <class Iterator> inline void join(const Iterator &Begin, const Iterator &End, const string &delim = "\n", const string &last = "\n") { for (auto it = Begin; it != End; ++it) { cout << ((it == Begin) ? "" : delim) << *it; } cout << last; } template <class T> inline vector<T> makeVector(const T &init_value, size_t sz) { return vector<T>(sz, init_value); } template <class T, class... Args> inline auto makeVector(const T &init_value, size_t sz, Args... args) { return vector<decltype(makeVector<T>(init_value, args...))>(sz, makeVector<T>(init_value, args...)); } template <class Func> class FixPoint : Func { public: explicit constexpr FixPoint(Func&& f) noexcept : Func(forward<Func>(f)) {} template <class... Args> constexpr decltype(auto) operator()(Args&&... args) const { return Func::operator()(*this, std::forward<Args>(args)...); } }; template <class Func> static inline constexpr decltype(auto) makeFixPoint(Func&& f) noexcept { return FixPoint<Func>{forward<Func>(f)}; } template <class Container> struct reverse_t { Container &c; reverse_t(Container &c) : c(c) {} auto begin() { return c.rbegin(); } auto end() { return c.rend(); } }; template <class Container> auto reversed(Container &c) { return reverse_t<Container>(c); } template <class T> inline bool chmax(T &a, const T &b) noexcept { return b > a && (a = b, true); } template <class T> inline bool chmin(T &a, const T &b) noexcept { return b < a && (a = b, true); } template <class T> inline T diff(const T &a, const T &b) noexcept { return a < b ? b - a : a - b; } void operator|=(vector<bool>::reference lhs, const bool rhs) { lhs = lhs | rhs; } void ioinit() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout << fixed << setprecision(10); cerr << fixed << setprecision(10); clog << fixed << setprecision(10); } // }}} End Header // Geometry {{{ const long double EPS = 1e-10; const long double PI = acos(-1); static const int CCW_COUNTER_CLOCKWISE = 1; static const int CCW_CLOCKWISE = -1; static const int CCW_ONLINE_BACK = 2; static const int CCW_ONLINE_FRONT = -2; static const int CCW_ON_SEGMENT = 0; static const int ICC_SEPARATE = 4; static const int ICC_CIRCUMSCRIBE = 3; static const int ICC_INTERSECT = 2; static const int ICC_INSCRIBE = 1; static const int ICC_CONTAIN = 0; struct Real { long double value; Real(long double value = 0) : value(value) {} Real(const Real& rhs) { value = rhs.value; } Real operator+(const Real& rhs) const { return Real(value + rhs.value); } Real& operator+=(const Real& rhs) { return value += rhs.value, *this; } Real operator-(const Real& rhs) const { return Real(value - rhs.value); } Real& operator-=(const Real& rhs) { return value -= rhs.value, *this; } Real operator*(const Real& rhs) const { return Real(value * rhs.value); } Real& operator*=(const Real& rhs) { return value *= rhs.value, *this; } Real operator/(const Real& rhs) const { return Real(value / rhs.value); } Real& operator/=(const Real& rhs) { return value /= rhs.value, *this; } Real operator-() const { return Real(-value); } Real& operator++() { return ++value, *this; } Real& operator--() { return --value, *this; } Real operator++(int) { Real tmp(value); return ++value, tmp; } Real operator--(int) { Real tmp(value); return --value, tmp; } bool operator==(const Real& rhs) const { return fabs(value - rhs.value) < EPS; } bool operator!=(const Real& rhs) const { return !(*this == rhs); } bool operator<(const Real& rhs) const { return (*this == rhs) ? false : value < rhs.value; } bool operator>(const Real& rhs) const { return (*this == rhs) ? false : value > rhs.value; } bool operator<=(const Real& rhs) const { return (*this == rhs) ? true : value < rhs.value; } bool operator>=(const Real& rhs) const { return (*this == rhs) ? true : value > rhs.value; } template <class T> explicit operator T() const { return static_cast<T>(value); } friend istream& operator>>(istream& is, Real& rhs) { is >> rhs.value; return is; } friend ostream& operator<<(ostream& os, const Real& rhs) { os << rhs.value; return os; } friend Real pow(const Real& n, const Real& p) { return pow(n.value, p.value); } friend Real pow(Real n, intmax_t p) { Real ret = 1; for (; p > 0; p >>= 1) { if (p & 1) ret *= n; n *= n; } return ret; } friend Real abs(const Real& rhs) { return abs(rhs.value); } friend Real sin(const Real& rhs) { return sin(rhs.value); } friend Real cos(const Real& rhs) { return cos(rhs.value); } friend Real tan(const Real& rhs) { return tan(rhs.value); } friend Real asin(const Real& rhs) { return asin(rhs.value); } friend Real acos(const Real& rhs) { return acos(rhs.value); } friend Real atan(const Real& rhs) { return atan(rhs.value); } friend Real atan2(const Real& lhs, const Real& rhs) { return atan2(lhs.value, rhs.value); } friend Real sqrt(const Real& rhs) { return sqrt(rhs.value); } friend Real ceil(const Real& rhs) { return ceil(rhs.value); } friend Real floor(const Real& rhs) { return floor(rhs.value); } friend Real round(const Real& rhs) { return round(rhs.value); } friend Real hypot(const Real& x, const Real& y) { return hypot(x.value, y.value); } friend Real hypot(const Real& x, const Real& y, const Real& z) { return hypot(x.value, y.value, z.value); } }; using real_t = Real; real_t operator""_r(long double value) { return value; }; struct Point { real_t x, y; Point(real_t x = 0, real_t y = 0) : x(x), y(y) {} Point operator+(const Point& rhs) const { return Point(x + rhs.x, y + rhs.y); } Point operator-(const Point& rhs) const { return Point(x - rhs.x, y - rhs.y); } Point operator*(const real_t& rhs) const { return Point(x * rhs, y * rhs); } Point operator/(const real_t& rhs) const { return Point(x / rhs, y / rhs); } Point operator-() const { return Point(-x, -y); } bool operator==(const Point& rhs) const { return x == rhs.x && y == rhs.y; } bool operator!=(const Point& rhs) const { return !(*this == rhs); } bool operator<(const Point& rhs) const { return (x == rhs.x) ? y < rhs.y : x < rhs.x; } bool operator>(const Point& rhs) const { return (x == rhs.x) ? y > rhs.y : x > rhs.x; } bool operator<=(const Point& rhs) const { return (*this == rhs) ? true : *this < rhs; } bool operator>=(const Point& rhs) const { return (*this == rhs) ? true : *this > rhs; } friend istream& operator>>(istream& is, Point& rhs) { is >> rhs.x >> rhs.y; return is; } friend ostream& operator<<(ostream& os, const Point& rhs) { os << rhs.x << ' ' << rhs.y; return os; } }; using Vector = Point; using Polygon = vector<Point>; real_t norm(const Vector& a) { return a.x * a.x + a.y * a.y; } real_t len(const Vector& a) { return sqrt(norm(a)); } real_t dot(const Vector& a, const Vector& b) { return a.x * b.x + a.y * b.y; } real_t cross(const Vector& a, const Vector& b) { return a.x * b.y - a.y * b.x; } struct Segment { Point p1, p2; Segment(Point p1 = Point(), Point p2 = Point()) : p1(p1), p2(p2) {} bool operator==(const Segment& rhs) const { return p1 == rhs.p1 && p2 == rhs.p2; } bool operator!=(const Segment& rhs) const { return !(*this == rhs); } friend istream& operator>>(istream& is, Segment& rhs) { is >> rhs.p1 >> rhs.p2; return is; } friend ostream& operator<<(ostream& os, const Segment& rhs) { os << rhs.p1 << ' ' << rhs.p2; return os; } }; using Line = Segment; struct Circle { Point c; real_t r; Circle(Point c = Point(), real_t r = 0) : c(c), r(r) {} bool operator==(const Circle& rhs) const { return c == rhs.c && r == rhs.r; } bool operator!=(const Circle& rhs) const { return !(*this == rhs); } friend istream& operator>>(istream& is, Circle& rhs) { is >> rhs.c >> rhs.r; return is; } friend ostream& operator<<(ostream& os, const Circle& rhs) { os << rhs.c << ' ' << rhs.r; return os; } }; real_t len(const Segment& s) { return len(s.p1 - s.p2); } bool isParallel(const Vector& a, const Vector& b) { return cross(a, b) == 0.0_r; } bool isParallel(const Point& a1, const Point& a2, const Point& b1, const Point& b2) { return isParallel(a1 - a2, b1 - b2); } bool isParallel(const Segment& s1, const Segment& s2) { return isParallel(s1.p1, s1.p2, s2.p1, s2.p2); } bool isOrthogonal(const Vector& a, const Vector& b) { return dot(a, b) == 0.0_r; } bool isOrthogonal(const Point& a1, const Point& a2, const Point& b1, const Point& b2) { return isOrthogonal(a1 - a2, b1 - b2); } bool isOrthogonal(const Segment& s1, const Segment& s2) { return isOrthogonal(s1.p1, s1.p2, s2.p1, s2.p2); } Point project(const Segment& s, const Point& p) { const Vector base = s.p2 - s.p1; const Vector hypo = p - s.p1; const real_t r = dot(hypo, base) / norm(base); return s.p1 + base * r; } Point reflect(const Segment& s, const Point& p) { return p + (project(s, p) - p) * 2.0; } real_t arg(const Vector& p) { return atan2(p.y, p.x); } Vector polar(real_t r, real_t ang) { return Point(r * cos(ang), r * sin(ang)); } int ccw(const Point& p0, const Point& p1, const Point& p2); bool intersectSS(const Point& p1, const Point& p2, const Point& p3, const Point& p4); bool intersectSS(const Segment& s1, const Segment& s2); bool intersectSG(const Segment& s, const Polygon& g); int intersectCC(Circle c1, Circle c2); bool intersectLC(const Line& l, const Circle& c); int intersectSC(const Segment& s, const Circle& c); real_t getDistancePP(const Point& p1, const Point& p2); real_t getDistanceLP(const Line& l, const Point& p); real_t getDistanceSP(const Segment& s, const Point& p); real_t getDistanceSS(const Segment& s1, const Segment& s2); Point getcrossPointSS(const Segment& s1, const Segment& s2); Point getcrossPointLL(const Line& l1, const Line& l2); Polygon getcrossPointLC(const Line& l, const Circle& c); Polygon getcrossPointSC(const Segment& s, const Circle& c); Polygon getcrossPointCC(const Circle &c1, const Circle &c2); bool isConvex(const Polygon& g); int contains(const Polygon& g, const Point& p); int convexContains(const Polygon& g, const Point& p); Polygon convexFull(Polygon g, bool ONSEG); real_t area(const Polygon& g); int ccw(const Point& p0, const Point& p1, const Point& p2) { Vector a = p1 - p0; Vector b = p2 - p0; if (cross(a, b) > 0.0_r) return CCW_COUNTER_CLOCKWISE; if (cross(a, b) < 0.0_r) return CCW_CLOCKWISE; if (dot(a, b) < 0.0_r) return CCW_ONLINE_BACK; if (norm(a) < norm(b)) return CCW_ONLINE_FRONT; return CCW_ON_SEGMENT; } bool intersectSS(const Point& p1, const Point& p2, const Point& p3, const Point& p4) { return ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0; } bool intersectSS(const Segment& s1, const Segment& s2) { return intersectSS(s1.p1, s1.p2, s2.p1, s2.p2); } bool intersectSG(const Segment& s, const Polygon& g) { const size_t N = g.size(); for (size_t i = 0; i < N; ++i) { if (intersectSS(Segment(g[i], g[(i + 1) % N]), s)) return true; } return false; } int intersectCC(Circle c1, Circle c2) { if (c1.r < c2.r) swap(c1, c2); const real_t d = len(c1.c - c2.c); const real_t r = c1.r + c2.r; if (d == r) return ICC_CIRCUMSCRIBE; if (d > r) return ICC_SEPARATE; if (d + c2.r == c1.r) return ICC_INSCRIBE; if (d + c2.r < c1.r) return ICC_CONTAIN; return ICC_INTERSECT; } bool intersectLC(const Line& l, const Circle& c) { return getDistanceSP(l, c.c) <= c.r; } int intersectSC(const Segment& s, const Circle& c) { const Point h = project(s, c.c); if (norm(h - c.c) - c.r * c.r > 0.0_r) return 0; const real_t d1 = getDistancePP(c.c, s.p1); const real_t d2 = getDistancePP(c.c, s.p2); if (d1 < c.r && d2 < c.r) return 0; if ((d1 < c.r && d2 > c.r) || (d1 > c.r && d2 < c.r)) return 1; if (dot(s.p1 - h, s.p2 - h) < 0.0_r) return 2; return 0; } real_t getDistancePP(const Point& p1, const Point& p2) { return len(p2 - p1); } real_t getDistanceLP(const Line& l, const Point& p) { return abs(cross(l.p2 - l.p1, p - l.p1) / len(l.p2 - l.p1)); } real_t getDistanceSP(const Segment& s, const Point& p) { if (dot(s.p2 - s.p1, p - s.p1) < 0.0_r) return getDistancePP(p, s.p1); if (dot(s.p1 - s.p2, p - s.p2) < 0.0_r) return getDistancePP(p, s.p2); return getDistanceLP(s, p); } real_t getDistanceSS(const Segment& s1, const Segment& s2) { if (intersectSS(s1, s2)) return 0.0; const real_t opt1 = getDistanceSP(s1, s2.p1); const real_t opt2 = getDistanceSP(s1, s2.p2); const real_t opt3 = getDistanceSP(s2, s1.p1); const real_t opt4 = getDistanceSP(s2, s1.p2); return min({opt1, opt2, opt3, opt4}); } Point getcrossPointSS(const Segment& s1, const Segment& s2) { Vector base = s2.p2 - s2.p1; const real_t d1 = abs(cross(base, s1.p1 - s2.p1)); const real_t d2 = abs(cross(base, s1.p2 - s2.p1)); const real_t t = d1 / (d1 + d2); return s1.p1 + (s1.p2 - s1.p1) * t; } Polygon getcrossPointLC(const Line& l, const Circle& c) { Polygon ps; const Point pr = project(l, c.c); const Vector e = (l.p2 - l.p1) / len(l.p2 - l.p1); if (getDistanceLP(l, c.c) == c.r) { ps.emplace_back(pr); return ps; } const real_t base = sqrt(c.r * c.r - norm(pr - c.c)); ps.emplace_back(pr + e * base); ps.emplace_back(pr - e * base); return ps; } Polygon getcrossPointSC(const Segment& s, const Circle& c) { const Line l(s); Polygon ret = getcrossPointLC(l, c); if (intersectSC(s, c) == 2) return ret; if (ret.size() > 1) { if (dot(l.p1 - ret[0], l.p2 - ret[0]) > 0.0_r) swap(ret[0], ret[1]); ret.pop_back(); } return ret; } Polygon getcrossPointCC(const Circle& c1, const Circle& c2) { Polygon p(2); const real_t d = getDistancePP(c1.c, c2.c); const real_t a = acos((c1.r * c1.r + d * d - c2.r * c2.r) / (2.0_r * c1.r * d)); const real_t t = arg(c2.c - c1.c); p[0] = c1.c + polar(c1.r, t + a); p[1] = c1.c + polar(c1.r, t - a); return p; } bool isConvex(const Polygon& g) { const size_t N = g.size(); for (size_t i = 0; i < N; ++i) { const int state = ccw(g[i], g[(i + 1) % N], g[(i + 2) % N]); if (state == CCW_CLOCKWISE) return false; } return true; } // OUT:0 ON:1 IN:2 enum { OUT, ON, IN }; int contains(const Polygon& g, const Point& p) { const size_t N = g.size(); bool valid = false; for (size_t i = 0; i < N; ++i) { Point a = g[i] - p, b = g[(i + 1) % N] - p; if (abs(cross(a, b)) == 0.0_r && dot(a, b) <= 0.0_r) return ON; if (a.y > b.y) swap(a, b); if (a.y <= 0.0_r && 0.0_r < b.y && cross(a, b) > 0.0_r) valid ^= 1; } return (valid ? IN : OUT); } // time complexity: O(log N) int convexContains(const Polygon& g, const Point& p) { const size_t N = g.size(); const Point G = (g[0] + g[N / 3] + g[2 * N / 3]) / 3.0_r; size_t l = 0, r = N; while (r - l > 1) { const size_t m = (l + r) / 2; if (cross(g[l] - G, g[m] - G) > 0.0_r) { if (cross(g[l] - G, p - G) > 0.0_r && cross(g[m] - G, p - G) < 0.0_r) r = m; else l = m; } else { if (cross(g[l] - G, p - G) < 0.0_r && cross(g[m] - G, p - G) > 0.0_r) l = m; else r = m; } } r %= N; if (cross(g[l] - p, g[r] - p) < 0.0_r) return OUT; if (cross(g[l] - p, g[r] - p) > 0.0_r) return IN; return ON; } // Counter Clockwise Polygon convexFull(Polygon g, bool ONSEG) { Polygon u, l; if (g.size() < 3) return g; sort(g.begin(), g.end()); u.emplace_back(g[0]); u.emplace_back(g[1]); l.emplace_back(g[g.size() - 1]); l.emplace_back(g[g.size() - 2]); if (ONSEG) { for (int i = 2; i < g.size(); ++i) { for (int n = u.size(); n >= 2 && ccw(u[n - 2], u[n - 1], g[i]) == CCW_COUNTER_CLOCKWISE; --n) { u.pop_back(); } u.emplace_back(g[i]); } for (int i = g.size() - 3; i >= 0; --i) { for (int n = l.size(); n >= 2 && ccw(l[n - 2], l[n - 1], g[i]) == CCW_COUNTER_CLOCKWISE; --n) { l.pop_back(); } l.emplace_back(g[i]); } } else { for (int i = 2; i < g.size(); ++i) { for (int n = u.size(); n >= 2 && ccw(u[n - 2], u[n - 1], g[i]) != CCW_CLOCKWISE; --n) { u.pop_back(); } u.emplace_back(g[i]); } for (int i = g.size() - 3; i >= 0; --i) { for (int n = l.size(); n >= 2 && ccw(l[n - 2], l[n - 1], g[i]) != CCW_CLOCKWISE; --n) { l.pop_back(); } l.emplace_back(g[i]); } } reverse(l.begin(), l.end()); for (int i = u.size() - 2; i >= 1; --i) l.emplace_back(u[i]); return l; } real_t area(const Polygon& g) { const size_t N = g.size(); real_t res = 0; for (size_t i = 0; i < g.size(); ++i) { res += cross(g[i], g[(i + 1) % N]) / 2.0; } return res; } // time complexity: expected value O(N) Circle minimumInclusionCircle(Polygon g) { const size_t N = g.size(); assert(N >= 1); if (N == 1) { return {g[0], 0.0_r}; } random_device seed_gen; mt19937 engine(seed_gen()); shuffle(g.begin(), g.end(), engine); const auto makeCircle3 = [](const Point& a, const Point& b, const Point& c) -> Circle { const real_t A = norm(b - c), B = norm(c - a), C = norm(a - b), S = cross(b - a, c - a); const Point p = (a * (A * (B + C - A)) + b * (B * (C + A - B)) + c * (C * (A + B - C))) / (4.0_r * S * S); const real_t r2 = getDistancePP(p, a); return {p, r2}; }; const auto makeCircle2 = [](const Point& a, const Point& b) -> Circle { const Point c = (a + b) / 2.0_r; const real_t r2 = getDistancePP(a, c); return {c, r2}; }; const auto inCircle = [](const Point& a, const Circle& c) -> bool { return getDistancePP(a, c.c) <= c.r; }; Circle c = makeCircle2(g[0], g[1]); for (size_t i = 2; i < N; ++i) { if (!inCircle(g[i], c)) { c = makeCircle2(g[0], g[i]); for (size_t j = 1; j < i; ++j) { if (!inCircle(g[j], c)) { c = makeCircle2(g[i], g[j]); for (size_t k = 0; k < j; ++k) { if (!inCircle(g[k], c)) { c = makeCircle3(g[i], g[j], g[k]); } } } } } } return c; } // }}} int main() { ioinit(); var(size_t, N, K); vector<intmax_t> as(N); input(as); sort(rall(as)); intmax_t res = 0; rep(mask, 0, 1 << (N - 1)) { intmax_t val = K; rep(i, 0, N - 1) { if (mask >> i & 1) { val %= as[i]; } } val %= as.back(); chmax(res, val); } output(res); return 0; }