// #pragma GCC optimize("O3,unroll-loops") #include // #include using namespace std; #if __cplusplus >= 202002L using namespace numbers; #endif template struct point{ T x{}, y{}; point(){ } template point(const point &otr): x(otr.x), y(otr.y){ } template point(U x, V y): x(x), y(y){ } template point(const array &p): x(p[0]), y(p[1]){ } friend istream &operator>>(istream &in, point &p){ return in >> p.x >> p.y; } friend ostream &operator<<(ostream &out, const point &p){ return out << "{" << p.x << ", " << p.y << "}"; } template operator array() const{ return {x, y}; } T operator*(const point &otr) const{ return x * otr.x + y * otr.y; } T operator^(const point &otr) const{ return x * otr.y - y * otr.x; } point operator+(const point &otr) const{ return {x + otr.x, y + otr.y}; } point &operator+=(const point &otr){ return *this = *this + otr; } point operator-(const point &otr) const{ return {x - otr.x, y - otr.y}; } point &operator-=(const point &otr){ return *this = *this - otr; } point operator-() const{ return {-x, -y}; } #define scalarop_l(op) friend point operator op(const T &c, const point &p){ return {c op p.x, c op p.y}; } scalarop_l(+) scalarop_l(-) scalarop_l(*) scalarop_l(/) #define scalarop_r(op) point operator op(const T &c) const{ return {x op c, y op c}; } scalarop_r(+) scalarop_r(-) scalarop_r(*) scalarop_r(/) #define scalarapply(applyop, op) point &operator applyop(const T &c){ return *this = *this op c; } scalarapply(+=, +) scalarapply(-=, -) scalarapply(*=, *) scalarapply(/=, /) #define compareop(op) bool operator op(const point &otr) const{ return pair(x, y) op pair(otr.x, otr.y); } compareop(>) compareop(<) compareop(>=) compareop(<=) compareop(==) compareop(!=) #undef scalarop_l #undef scalarop_r #undef scalarapply #undef compareop double norm() const{ return sqrt(x * x + y * y); } long double norm_l() const{ return sqrtl(x * x + y * y); } T squared_norm() const{ return x * x + y * y; } // [0, 2 * pi] double angle() const{ auto a = atan2(y, x); if(a < 0) a += 2 * acos(-1); return a; } // [0, 2 * pi] long double angle_l() const{ auto a = atan2(y, x); if(a < 0) a += 2 * acosl(-1); return a; } point unit() const{ return point(x, y) / norm(); } point unit_l() const{ return point(x, y) / norm_l(); } point perp() const{ return {-y, x}; } point normal() const{ return perp().unit(); } point normal_l() const{ return perp().unit_l(); } point rotate(double theta) const{ return {x * cos(theta) - y * sin(theta), x * sin(theta) + y * cos(theta)}; } point rotate_l(double theta) const{ return {x * cosl(theta) - y * sinl(theta), x * sinl(theta) + y * cosl(theta)}; } point reflect_x() const{ return {x, -y}; } point reflect_y() const{ return {-x, y}; } point reflect(const point &o = {}) const{ return {2 * o.x - x, 2 * o.y - y}; } bool parallel_to(const point &q) const{ if constexpr(is_floating_point_v) return abs(*this ^ q) <= 1e-9; else return abs(*this ^ q) == 0; } }; template point lerp(const point &p, const point &q, double t){ return point(p) * (1 - t) + point(q) * t; } template point lerp_l(const point &p, const point &q, long double t){ return point(p) * (1 - t) + point(q) * t; } template double distance(const point &p, const point &q){ return (p - q).norm(); } template long double distance_l(const point &p, const point &q){ return (p - q).norm_l(); } template T squared_distance(const point &p, const point &q){ return (p - q).squared_norm(); } template T doubled_signed_area(const point &p, const point &q, const point &r){ return q - p ^ r - p; } template T doubled_signed_area(const vector> &a){ if(a.empty()) return 0; T res = a.back() ^ a.front(); for(auto i = 1; i < (int)a.size(); ++ i) res += a[i - 1] ^ a[i]; return res; } // [-pi, pi] template double angle(const point &p, const point &q){ return atan2(p ^ q, p * q); } // [-pi, pi] template long double angle_l(const point &p, const point &q){ return atan2l(p ^ q, p * q); } // Check if p->q->r is sorted by angle with respect to the origin template bool is_sorted_by_angle(const point &origin, const point &p, const point &q, const point &r){ T x = p - origin ^ q - origin; T y = q - origin ^ r - origin; if(x >= 0 && y >= 0) return true; if(x < 0 && y < 0) return false; return (p - origin ^ r - origin) < 0; } // Check if a is sorted by angle with respect to the origin template bool is_sorted_by_angle(const point &origin, const vector> &a){ for(auto i = 0; i < (int)a.size() - 2; ++ i) if(!is_sorted_by_angle(origin, a[i], a[i + 1], a[i + 2])) return false; return true; } template bool counterclockwise(const point &p, const point &q, const point &r){ return doubled_signed_area(p, q, r) > 0; } template bool clockwise(const point &p, const point &q, const point &r){ return doubled_signed_area(p, q, r) < 0; } template bool colinear(const point &p, const point &q, const point &r){ return doubled_signed_area(p, q, r) == 0; } template bool colinear(const vector> &a){ int i = 1; while(i < (int)a.size() && a[0] == a[i]) ++ i; if(i == (int)a.size()) return true; for(auto j = i + 1; j < (int)a.size(); ++ j) if(!colinear(a[0], a[i], a[j])) return false; return true; } point polar(double x, double theta){ assert(x >= 0); return {x * cos(theta), x * sin(theta)}; } point polar_l(long double x, long double theta){ assert(x >= 0); return {x * cosl(theta), x * sinl(theta)}; } // T must be able to hold the fourth power of max coordinate // returns [a, b, c, and d lies in a circle] template bool concircular(point a, point b, point c, const point &d){ a -= d, b -= d, c -= d; return a.squared_norm() * (b ^ c) + b.squared_norm() * (c ^ a) + c.squared_norm() * (a ^ b) == 0; } // T must be able to hold the fourth power of max coordinate // returns [d lies in the interior of the circle defined by a, b, c] template bool inside_of_circle(point a, point b, point c, const point &d){ a -= d, b -= d, c -= d; return (a.squared_norm() * (b ^ c) + b.squared_norm() * (c ^ a) + c.squared_norm() * (a ^ b)) * (doubled_signed_area(a, b, c) > 0 ? 1 : -1) > 0; } // T must be able to hold the fourth power of max coordinate // returns [d lies in the exterior of the circle defined by a, b, c] template bool outside_of_circle(point a, point b, point c, const point &d){ a -= d, b -= d, c -= d; return (a.squared_norm() * (b ^ c) + b.squared_norm() * (c ^ a) + c.squared_norm() * (a ^ b)) * (doubled_signed_area(a, b, c) > 0 ? -1 : 1) > 0; } using pointint = point; using pointll = point; using pointlll = point<__int128_t>; using pointd = point; using pointld = point; int main(){ cin.tie(0)->sync_with_stdio(0); cin.exceptions(ios::badbit | ios::failbit); cout << fixed << setprecision(15); long double k; pointld a, b, c; cin >> k >> a >> b >> c; pointld dx = (b - a).unit(); pointld dy = dx.normal(); if(dy * c < 0){ dy = -dy; } auto dist = [&](pointld p, pointld q)->long double{ return pow(abs(p.x - q.x), k) + pow(abs(p.y - q.y), k); }; auto search_x = [&](long double y)->long double{ long double low = -1e7, high = 1e7; for(auto rep = 400; rep; -- rep){ long double mid = (low + high) / 2; dist(a, dx * mid + dy * y) > dist(b, dx * mid + dy * y) ? high = mid : low = mid; } return (low + high) / 2; }; auto search_y = [&]()->long double{ long double low = -1e7, high = 1e7; for(auto rep = 400; rep; -- rep){ long double mid = (low + high) / 2; long double x = search_x(mid); dist(a, dx * x + dy * mid) > dist(c, dx * x + dy * mid) ? high = mid : low = mid; } return (low + high) / 2; }; long double y = search_y(); long double x = search_x(y); auto res = dx * x + dy * y; cout << res.x << " " << res.y << "\n"; return 0; } /* */