Problem:
 Score : 600 points    Problem Statement Takahashi wants to grill N pieces of meat on a grilling net, which can be seen as a two-dimensional plane. The coordinates of the i -th piece of meat are \left(x_i, y_i\right) , and its hardness is c_i .  Takahashi can use one heat source to grill the meat. If he puts the heat source at coordinates \left(X, Y\right) , where X and Y are real numbers, the i -th piece of meat will be ready to eat in c_i \times \sqrt{\left(X - x_i\right)^2 + \left(Y-y_i\right)^2} seconds.  Takahashi wants to eat K pieces of meat. Find the time required to have K or more pieces of meat ready if he put the heat source to minimize this time.      Constraints  All values in input are integers.  1 \leq N \leq 60  1 \leq K \leq N  -1000 \leq x_i , y_i \leq 1000  \left(x_i, y_i\right) \neq \left(x_j, y_j\right) \left(i \neq j \right)  1 \leq c_i \leq 100         Input Input is given from Standard Input in the following format:  N  K  x_1  y_1  c_1  \vdots  x_N  y_N  c_N       Output Print the answer.  It will be considered correct if its absolute or relative error from our answer is at most 10^{-6} .        Sample Input 1 4 3
-1 0 3
0 0 3
1 0 2
1 1 40      Sample Output 1 2.4  If we put the heat source at \left(-0.2, 0\right) , the 1 -st, 2 -nd, and 3 -rd pieces of meat will be ready to eat within 2.4 seconds. This is the optimal place to put the heat source.       Sample Input 2 10 5
-879 981 26
890 -406 81
512 859 97
362 -955 25
128 553 17
-885 763 2
449 310 57
-656 -204 11
-270 76 40
184 170 16      Sample Output 2 7411.2252

Solution (Python):
import cmath
import itertools
import math
import os
import random
import sys

INF = float("inf")
PI = cmath.pi
TAU = cmath.pi * 2
EPS = 1e-8


class Point:
    """
    2次元空間上の点
    """

    
    CCW_COUNTER_CLOCKWISE = 1
    
    CCW_CLOCKWISE = -1
    
    CCW_ONLINE_BACK = 2
    
    CCW_ONLINE_FRONT = -2
    
    CCW_ON_SEGMENT = 0

    def __init__(self, x: float, y: float):
        self.c = complex(x, y)

    @property
    def x(self):
        return self.c.real

    @property
    def y(self):
        return self.c.imag

    @staticmethod
    def from_complex(c: complex):
        return Point(c.real, c.imag)

    @staticmethod
    def from_polar(r: float, phi: float):
        c = cmath.rect(r, phi)
        return Point(c.real, c.imag)

    def __add__(self, p):
        """
        :param Point p:
        """
        c = self.c + p.c
        return Point(c.real, c.imag)

    def __iadd__(self, p):
        """
        :param Point p:
        """
        self.c += p.c
        return self

    def __sub__(self, p):
        """
        :param Point p:
        """
        c = self.c - p.c
        return Point(c.real, c.imag)

    def __isub__(self, p):
        """
        :param Point p:
        """
        self.c -= p.c
        return self

    def __mul__(self, f: float):
        c = self.c * f
        return Point(c.real, c.imag)

    def __imul__(self, f: float):
        self.c *= f
        return self

    def __truediv__(self, f: float):
        c = self.c / f
        return Point(c.real, c.imag)

    def __itruediv__(self, f: float):
        self.c /= f
        return self

    def __repr__(self):
        return "({}, {})".format(round(self.x, 10), round(self.y, 10))

    def __neg__(self):
        c = -self.c
        return Point(c.real, c.imag)

    def __eq__(self, p):
        return abs(self.c - p.c) < EPS

    def __abs__(self):
        return abs(self.c)

    def __lt__(self, p):
        return self.x - p.x < -EPS or self.x - p.x < EPS and self.y - p.y < -EPS

    def __le__(self, p):
        return self.x - p.x < -EPS or self.x - p.x < EPS and self.y - p.y < EPS

    def __gt__(self, p):
        return self.x - p.x > EPS or self.x - p.x > -EPS and self.y - p.y > EPS

    def __ge__(self, p):
        return self.x - p.x > EPS or self.x - p.x > -EPS and self.y - p.y > -EPS

    @staticmethod
    def ccw(a, b, c):
        """
        線分 ab に対する c の位置
        線分上にあるか判定するだけなら on_segment とかのが速い
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_C&lang=ja
        :param Point a:
        :param Point b:
        :param Point c:
        """
        b = b - a
        c = c - a
        det = b.det(c)
        if det > EPS:
            return Point.CCW_COUNTER_CLOCKWISE
        if det < -EPS:
            return Point.CCW_CLOCKWISE
        if b.dot(c) < -EPS:
            return Point.CCW_ONLINE_BACK
        if b.dot(b - c) < -EPS:
            return Point.CCW_ONLINE_FRONT
        return Point.CCW_ON_SEGMENT

    def dot(self, p):
        """
        内積
        :param Point p:
        :rtype: float
        """
        return self.x * p.x + self.y * p.y

    def det(self, p):
        """
        外積
        :param Point p:
        :rtype: float
        """
        return self.x * p.y - self.y * p.x

    def dist(self, p):
        """
        距離
        :param Point p:
        :rtype: float
        """
        return abs(self.c - p.c)

    def norm(self):
        """
        原点からの距離
        :rtype: float
        """
        return abs(self.c)

    def phase(self):
        """
        原点からの角度
        :rtype: float
        """
        return cmath.phase(self.c)

    def angle(self, p, q):
        """
        p に向いてる状態から q まで反時計回りに回転するときの角度
        -pi <= ret <= pi
        :param Point p:
        :param Point q:
        :rtype: float
        """
        return (cmath.phase(q.c - self.c) - cmath.phase(p.c - self.c) + PI) % TAU - PI

    def area(self, p, q):
        """
        p, q となす三角形の面積
        :param Point p:
        :param Point q:
        :rtype: float
        """
        return -abs((p - self).det(q - self) / 2)

    def projection_point(self, p, q, allow_outer=False):
        """
        線分 pq を通る直線上に垂線をおろしたときの足の座標
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_A&lang=ja
        :param Point p:
        :param Point q:
        :param allow_outer: 答えが線分の間になくても OK
        :rtype: Point|None
        """
        diff_q = q - p
        
        r = (self - p).dot(diff_q) / abs(diff_q)
        
        phase = diff_q.phase()

        ret = Point.from_polar(r, phase) + p
        if allow_outer or (p - ret).dot(q - ret) < EPS:
            return ret
        return None

    def reflection_point(self, p, q):
        """
        直線 pq を挟んで反対にある点
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_B&lang=ja
        :param Point p:
        :param Point q:
        :rtype: Point
        """
        
        r = abs(self - p)
        
        angle = p.angle(q, self)
        
        angle = (q - p).phase() - angle
        return Point.from_polar(r, angle) + p

    def on_segment(self, p, q, allow_side=True):
        """
        点が線分 pq の上に乗っているか
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_1_C&lang=ja
        :param Point p:
        :param Point q:
        :param allow_side: 端っこでギリギリ触れているのを許容するか
        :rtype: bool
        """
        if not allow_side and (self == p or self == q):
            return False
        
        
        return abs((p - self).det(q - self)) < EPS and (p - self).dot(q - self) < EPS

    @staticmethod
    def circumcenter_of(p1, p2, p3):
        """
        外心
        :param Point p1:
        :param Point p2:
        :param Point p3:
        :rtype: Point|None
        """
        if abs((p2 - p1).det(p3 - p1)) < EPS:
            
            return None
        
        a = (p2.x - p3.x) ** 2 + (p2.y - p3.y) ** 2
        b = (p3.x - p1.x) ** 2 + (p3.y - p1.y) ** 2
        c = (p1.x - p2.x) ** 2 + (p1.y - p2.y) ** 2
        num = p1 * a * (b + c - a) + p2 * b * (c + a - b) + p3 * c * (a + b - c)
        den = a * (b + c - a) + b * (c + a - b) + c * (a + b - c)
        return num / den

    @staticmethod
    def incenter_of(p1, p2, p3):
        """
        内心
        :param Point p1:
        :param Point p2:
        :param Point p3:
        """
        
        d1 = p2.dist(p3)
        d2 = p3.dist(p1)
        d3 = p1.dist(p2)
        return (p1 * d1 + p2 * d2 + p3 * d3) / (d1 + d2 + d3)


class Circle:
    def __init__(self, o, r):
        """
        :param Point o:
        :param float r:
        """
        self.o = o
        self.r = r

    def __eq__(self, other):
        return self.o == other.o and abs(self.r - other.r) < EPS

    def ctc(self, c):
        """
        共通接線 common tangent の数
        4: 離れてる
        3: 外接
        2: 交わってる
        1: 内接
        0: 内包
        inf: 同一
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_A&lang=ja
        :param Circle c:
        :rtype: int
        """
        if self.o == c.o:
            return INF if abs(self.r - c.r) < EPS else 0
        
        d = self.o.dist(c.o) - self.r - c.r
        if d > EPS:
            return 4
        elif d > -EPS:
            return 3
        
        elif d + min(self.r, c.r) * 2 > EPS:
            return 2
        elif d + min(self.r, c.r) * 2 > -EPS:
            return 1
        return 0

    def has_point_on_edge(self, p):
        """
        指定した点が円周上にあるか
        :param Point p:
        :rtype: bool
        """
        return abs(self.o.dist(p) - self.r) < EPS

    def contains(self, p, allow_on_edge=True):
        """
        指定した点を含むか
        :param Point p:
        :param bool allow_on_edge: 辺上の点を許容するか
        """
        if allow_on_edge:
            
            return self.o.dist(p) - self.r < EPS
        else:
            
            return self.o.dist(p) - self.r < -EPS

    def area(self):
        """
        面積
        """
        return self.r ** 2 * PI

    def circular_segment_area(self, angle):
        """
        弓形⌓の面積
        :param float angle: 角度ラジアン
        """
        
        sector_area = self.area() * angle / TAU
        
        return sector_area - self.r ** 2 * math.sin(angle) / 2

    def intersection_points(self, other, allow_outer=False):
        """
        :param Segment|Circle other:
        :param bool allow_outer:
        """
        if isinstance(other, Segment):
            return self.intersection_points_with_segment(other, allow_outer=allow_outer)
        if isinstance(other, Circle):
            return self.intersection_points_with_circle(other)
        raise NotImplementedError()

    def intersection_points_with_segment(self, s, allow_outer=False):
        """
        線分と交差する点のリスト
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_D&lang=ja
        :param Segment s:
        :param bool allow_outer: 線分の間にない点を含む
        :rtype: list of Point
        """
        
        projection_point = self.o.projection_point(s.p1, s.p2, allow_outer=True)
        
        dist = self.o.dist(projection_point)
        
        if dist - self.r > EPS:
            return []
        if dist - self.r > -EPS:
            if allow_outer or s.has_point(projection_point):
                return [projection_point]
            else:
                return []
        
        diff = Point.from_polar(math.sqrt(self.r ** 2 - dist ** 2), s.phase())
        ret1 = projection_point + diff
        ret2 = projection_point - diff
        ret = []
        if allow_outer or s.has_point(ret1):
            ret.append(ret1)
        if allow_outer or s.has_point(ret2):
            ret.append(ret2)
        return ret

    def intersection_points_with_circle(self, other):
        """
        円と交差する点のリスト
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_7_E&langja
        :param circle other:
        :rtype: list of Point
        """
        ctc = self.ctc(other)
        if not 1 <= ctc <= 3:
            return []
        if ctc == 3:
            
            return [Point.from_polar(self.r, (other.o - self.o).phase()) + self.o]
        if ctc == 1:
            
            if self.r > other.r:
                return [Point.from_polar(self.r, (other.o - self.o).phase()) + self.o]
            else:
                return [Point.from_polar(self.r, (self.o - other.o).phase()) + self.o]
        
        assert ctc == 2

        a = other.r
        b = self.r
        c = self.o.dist(other.o)
        
        cos_a = (b ** 2 + c ** 2 - a ** 2) / (2 * b * c)
        angle = math.acos(cos_a)
        phi = (other.o - self.o).phase()
        return [
            self.o + Point.from_polar(self.r, phi + angle),
            self.o + Point.from_polar(self.r, phi - angle),
        ]

    def tangent_points_with_point(self, p):
        """
        p を通る接線との接点
        :param Point p:
        :rtype: list of Point
        """
        dist = self.o.dist(p)
        
        if dist - self.r < -EPS:
            
            return []
        if dist - self.r < EPS:
            
            return [Point(p.x, p.y)]

        a = math.sqrt(dist ** 2 - self.r ** 2)
        b = self.r
        c = dist
        
        cos_a = (b ** 2 + c ** 2 - a ** 2) / (2 * b * c)
        angle = math.acos(cos_a)
        phi = (p - self.o).phase()
        return [
            self.o + Point.from_polar(self.r, phi + angle),
            self.o + Point.from_polar(self.r, phi - angle),
        ]

    def tangent_points_with_circle(self, other):
        """
        other との共通接線との接点
        :param Circle other:
        :rtype: list of Point
        """
        ctc = self.ctc(other)
        if ctc > 4:
            raise ValueError('2つの円が同一です')
        if ctc == 0:
            return []
        if ctc == 1:
            return self.intersection_points_with_circle(other)

        assert ctc in (2, 3, 4)
        ret = []
        
        
        if abs(self.r - other.r) < EPS:
            
            phi = (other.o - self.o).phase()
            ret.append(self.o + Point.from_polar(self.r, phi + PI / 2))
            ret.append(self.o + Point.from_polar(self.r, phi - PI / 2))
        else:
            
            intersection = self.o + (other.o - self.o) / (self.r - other.r) * self.r
            ret += self.tangent_points_with_point(intersection)

        
        
        intersection = self.o + (other.o - self.o) / (self.r + other.r) * self.r
        ret += self.tangent_points_with_point(intersection)
        return ret

    @staticmethod
    def circumscribed_of(p1, p2, p3):
        """
        p1・p2・p3 のなす三角形の外接円
        Verify:
        :param Point p1:
        :param Point p2:
        :param Point p3:
        """
        if p1.on_segment(p2, p3):
            return Circle((p2 + p3) / 2, p2.dist(p3) / 2)
        if p2.on_segment(p1, p3):
            return Circle((p1 + p3) / 2, p1.dist(p3) / 2)
        if p3.on_segment(p1, p2):
            return Circle((p1 + p2) / 2, p1.dist(p2) / 2)
        o = Point.circumcenter_of(p1, p2, p3)
        return Circle(o, o.dist(p1))

    @staticmethod
    def min_enclosing(points):
        """
        points をすべて含む最小の円
        計算量の期待値は O(N)
        https://www.jaist.ac.jp/~uehara/course/2014/i481f/pdf/ppt-7.pdf
        Verify: https://www.spoj.com/problems/QCJ4/
        :param list of Point points:
        :rtype: Circle
        """
        points = points[:]
        random.shuffle(points)

        
        ret = Circle(points[0], 0)
        for i, p in enumerate(points):
            if ret.contains(p):
                continue
            ret = Circle(p, 0)
            for j, q in enumerate(points[:i]):
                if ret.contains(q):
                    continue
                
                ret = Circle((p + q) / 2, abs(p - q) / 2)
                for k, r in enumerate(points[:j]):
                    if ret.contains(r):
                        continue
                    
                    ret = Circle.circumscribed_of(p, q, r)
        return ret


class Line:
    """
    2次元空間上の直線
    """

    def __init__(self, a: float, b: float, c: float):
        """
        直線 ax + by + c = 0
        """
        self.a = a
        self.b = b
        self.c = c

    @staticmethod
    def from_gradient(grad: float, intercept: float):
        """
        直線 y = ax + b
        :param grad: 傾き
        :param intercept: 切片
        :return:
        """
        return Line(grad, -1, intercept)

    @staticmethod
    def from_segment(p1, p2):
        """
        :param Point p1:
        :param Point p2:
        """
        a = p2.y - p1.y
        b = p1.x - p2.x
        c = p2.y * (p2.x - p1.x) - p2.x * (p2.y - p1.y)
        return Line(a, b, c)

    @property
    def gradient(self):
        """
        傾き
        """
        return INF if self.b == 0 else -self.a / self.b

    @property
    def intercept(self):
        """
        切片
        """
        return INF if self.b == 0 else -self.c / self.b

    def is_parallel_to(self, l):
        """
        平行かどうか
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A&lang=ja
        :param Line l:
        """
        
        return abs(Point(self.a, self.b).det(Point(l.a, l.b))) < EPS

    def is_orthogonal_to(self, l):
        """
        直行しているかどうか
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A&lang=ja
        :param Line l:
        """
        
        return abs(Point(self.a, self.b).dot(Point(l.a, l.b))) < EPS

    def intersection_point(self, l):
        """
        交差する点
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_C&lang=ja
        :param Line l:
        :rtype: Point|None
        """
        a1, b1, c1 = self.a, self.b, self.c
        a2, b2, c2 = l.a, l.b, l.c
        det = a1 * b2 - a2 * b1
        if abs(det) < EPS:
            
            return None
        x = (b1 * c2 - b2 * c1) / det
        y = (a2 * c1 - a1 * c2) / det
        return Point(x, y)

    def dist(self, p):
        """
        他の点との最短距離
        :param Point p:
        """
        raise NotImplementedError()

    def has_point(self, p):
        """
        p が直線上に乗っているかどうか
        :param Point p:
        """
        return abs(self.a * p.x + self.b * p.y + self.c) < EPS


class Segment:
    """
    2次元空間上の線分
    """

    def __init__(self, p1, p2):
        """
        :param Point p1:
        :param Point p2:
        """
        self.p1 = p1
        self.p2 = p2

    def norm(self):
        """
        線分の長さ
        """
        return abs(self.p1 - self.p2)

    def phase(self):
        """
        p1 を原点としたときの p2 の角度
        """
        return (self.p2 - self.p1).phase()

    def is_parallel_to(self, s):
        """
        平行かどうか
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A&lang=ja
        :param Segment s:
        :return:
        """
        
        return abs((self.p1 - self.p2).det(s.p1 - s.p2)) < EPS

    def is_orthogonal_to(self, s):
        """
        直行しているかどうか
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_A&lang=ja
        :param Segment s:
        :return:
        """
        
        return abs((self.p1 - self.p2).dot(s.p1 - s.p2)) < EPS

    def intersects_with(self, s, allow_side=True):
        """
        交差するかどうか
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_B&lang=ja
        :param Segment s:
        :param allow_side: 端っこでギリギリ触れているのを許容するか
        """
        if self.is_parallel_to(s):
            
            return (s.p1.on_segment(self.p1, self.p2, allow_side) or
                    s.p2.on_segment(self.p1, self.p2, allow_side) or
                    self.p1.on_segment(s.p1, s.p2, allow_side) or
                    self.p2.on_segment(s.p1, s.p2, allow_side))
        else:
            
            det_upper = EPS if allow_side else -EPS
            ok = True
            
            ok &= (self.p2 - self.p1).det(s.p1 - self.p1) * (self.p2 - self.p1).det(s.p2 - self.p1) < det_upper
            
            ok &= (s.p2 - s.p1).det(self.p1 - s.p1) * (s.p2 - s.p1).det(self.p2 - s.p1) < det_upper
            return ok

    def closest_point(self, p):
        """
        線分上の、p に最も近い点
        :param Point p:
        """
        
        d = (p - self.p1).dot(self.p2 - self.p1) / self.norm()
        
        if d < EPS:
            return self.p1
        
        if -EPS < d - self.norm():
            return self.p2
        
        return Point.from_polar(d, (self.p2 - self.p1).phase()) + self.p1

    def dist(self, p):
        """
        他の点との最短距離
        :param Point p:
        """
        return abs(p - self.closest_point(p))

    def dist_segment(self, s):
        """
        他の線分との最短距離
        Verify: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=CGL_2_D&lang=ja
        :param Segment s:
        """
        if self.intersects_with(s):
            return 0.0
        return min(
            self.dist(s.p1),
            self.dist(s.p2),
            s.dist(self.p1),
            s.dist(self.p2),
        )

    def has_point(self, p, allow_side=True):
        """
        p が線分上に乗っているかどうか
        :param Point p:
        :param allow_side: 端っこでギリギリ触れているのを許容するか
        """
        return p.on_segment(self.p1, self.p2, allow_side=allow_side)


if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7



N, K = list(map(int, sys.stdin.buffer.readline().split()))
XYC = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]




if K == 1:
    print(0)
    exit()

tp = []

for (x1, y1, c1), (x2, y2, c2) in itertools.combinations(XYC, r=2):
    p1 = Point(x1, y1)
    p2 = Point(x2, y2)
    I = p1 + (p2 - p1) / (100 / c1 + 100 / c2) * 100 / c1
    t = p1.dist(I) * c1
    tp.append((t, I))


def same_ratio_circle(p1, p2, ratio1, ratio2):
    
    i = p1 + (p2 - p1) * ratio1 / (ratio1 + ratio2)
    
    o = p1 + (p2 - p1) * ratio1 / (ratio1 - ratio2)
    return Circle((i + o) / 2, i.dist(o) / 2)





def intersection_points(f1, f2):
    if isinstance(f1, Circle):
        return f1.intersection_points(f2, allow_outer=True)
    elif isinstance(f2, Circle):
        return f2.intersection_points(f1, allow_outer=True)
    elif isinstance(f1, Segment) and isinstance(f2, Segment):
        ret = Line.from_segment(f1.p1, f1.p2).intersection_point(Line.from_segment(f2.p1, f2.p2))
        return [ret] if ret else []

    else:
        assert False



for (x1, y1, c1), (x2, y2, c2), (x3, y3, c3) in itertools.combinations(XYC, r=3):
    p1 = Point(x1, y1)
    p2 = Point(x2, y2)
    p3 = Point(x3, y3)
    
    
    
    

    figures = []
    for (p1, c1), (p2, c2) in itertools.combinations(((p1, c1), (p2, c2), (p3, c3)), 2):
        if c1 == c2:
            o = (p1 + p2) / 2
            figures.append(Segment(o, o + (p2 - p1) * 1j))
        else:
            figures.append(same_ratio_circle(p1, p2, 1 / c1, 1 / c2))
    
    ps1 = intersection_points(figures[0], figures[1])
    ps2 = intersection_points(figures[1], figures[2])
    ps3 = intersection_points(figures[2], figures[0])
    Is = []
    for p in ps1 + ps2 + ps3:
        for q in ps1:
            if p == q:
                break
        else:
            break
        for q in ps2:
            if p == q:
                break
        else:
            break
        for q in ps3:
            if p == q:
                break
        else:
            break
        Is.append(p)
    
    
    while Is:
        I = Is.pop()
        t = p1.dist(I) * c1
        tp.append((t, I))
        
        
        
        
        
        
        
        
        
tp.sort()

for t, p in tp:
    cnt = 0
    for x, y, c in XYC:
        cnt += Circle(Point(x, y), t / c).contains(p)
    if cnt >= K:
        print(t)
        break

Solution (Python):

import sys
input = sys.stdin.readline
import math
eps = 1e-12

def calc_intersection_points(circle0, circle1):
    x0, y0, r0 = circle0
    x1, y1, r1 = circle1
    d = math.hypot(x0 - x1, y0 - y1)
    if d > r0 + r1 or d < abs(r0 - r1):
        return []
    ret = []
    if r0 + r1 == d:
        a = r0
        h = 0.0
    else:
        a = (r0**2 - r1**2 + d**2) / (2.0 * d)
        h = math.sqrt(r0**2 - a**2)
    x2 = x0 + a * (x1 - x0) / d
    y2 = y0 + a * (y1 - y0) / d
    x3 = x2 + h * (y1 - y0) / d
    y3 = y2 - h * (x1 - x0) / d
    ret.append((x3, y3))
    if h == 0:
        return ret
    x4 = x2 - h * (y1 - y0) / d
    y4 = y2 + h * (x1 - x0) / d
    ret.append((x4, y4))
    return ret


n, k = map(int, input().split())
niku = []
for _ in range(n):
    x, y, c = map(int, input().split())
    niku.append((x, y, c))

l = 0.0; r = 10**8
for _ in range(64):
    mid = (l + r) / 2.0
    circles = []
    for x, y, c in niku:
        circles.append((x, y, mid / c))
    points = []
    for i in range(n):
        for j in range(i+1, n):
            points += calc_intersection_points(circles[i], circles[j])
    for x, y, _ in niku:
        points.append((x, y))
    cooked = 0
    for x, y in points:
        ret = 0
        for cx, cy, cr in circles:
            if math.hypot(x - cx, y - cy) <= cr + eps:
                ret += 1
        if ret > cooked:
            cooked = ret
    if cooked >= k:
        r = mid
    else:
        l = mid
print(l)

Solution (Python):
N, K = map(int, input().split())
xyc = [[int(i) for i in input().split()] for _ in range(N)]

def check(n) :
  for i in range(N) :
    xi, yi, ci = xyc[i]
    ri = n / ci
    for j in range(i + 1, N) :
      xj, yj, cj = xyc[j]
      xj -= xi
      yj -= yi
      rj = n / cj
      a = (xj ** 2 + yj ** 2 + ri ** 2 - rj ** 2) / 2
      root = max(0, (xj ** 2 + yj ** 2) * (ri ** 2) - a ** 2) ** 0.5
      for sgn in [1, -1] :
        cnt = 0
        X = (a * xj + sgn * yj * root) / (xj ** 2 + yj ** 2) + xi
        Y = (a * yj - sgn * xj * root) / (xj ** 2 + yj ** 2) + yi
        for x, y, c in xyc :
          if (x - X) ** 2 + (y - Y) ** 2 <= (n / c) ** 2 + eps :
            cnt += 1
        if cnt >= K :
          return True
  
  for X, Y, _ in xyc :
    cnt = 0
    for x, y, c in xyc :
      if (x - X) ** 2 + (y - Y) ** 2 <= (n / c) ** 2 + eps :
        cnt += 1
    if cnt >= K :
      return True
      
  return False

eps = 1e-8
ng, ok = 0, 10 ** 6
while ok - ng > eps :
  n = (ng + ok) / 2
  if check(n) :
    ok = n
  else :
    ng = n
 
print(ok)

Solution (Python):
def i1():
 return int(input())
def i2():
 return [int(i) for i in input().split()]
import math
[n,k]=i2()
d=[]
for i in range(n):
 d.append(i2())
eps=10**(-6)
def check(t):
 for x1,y1,c1 in d:
  for x2,y2,c2 in d:
   if x1==x2 and y1==y2:
      continue
   aa=2*(x1-x2)
   bb=2*(y1-y2)
   cc=t**2*(1/c2**2-1/c1**2)+x1**2-x2**2+y1**2-y2**2
   if aa==0:
      continue
   ss=bb**2/aa**2+1
   tt=bb/aa*(x1-cc/aa)-y1
   uu=(x1-cc/aa)**2+y1**2-(t/c1)**2
   if tt**2-ss*uu<0 or ss==0:
      continue
   Y1=-tt-math.sqrt(tt**2-ss*uu)
   Y1/=ss
   X1=(cc-bb*Y1)/aa
   count=0
   for x,y,c in d:
    if c*math.sqrt((X1-x)**2+(Y1-y)**2)<=t+eps:
      count+=1
   if count>=k:
    return True
   Y2=-tt+math.sqrt(tt**2-ss*uu)
   Y2/=ss
   X2=(cc-bb*Y2)/aa
   count=0
   for x,y,c in d:
    if c*math.sqrt((X2-x)**2+(Y2-y)**2)<=t+eps:
      count+=1
   if count>=k:
    return True
 for X,Y,C in d:
   count=0
   for x,y,c in d:
    if c*math.sqrt((X-x)**2+(Y-y)**2)<=t+eps:
      count+=1
   if count>=k:
    return True
 return False

low=0
high=100*3000

while high-low>eps:
  mid=(low+high)/2
  if check(mid):
     high=mid
  else:
     low=mid
print(high)

Solution (Python):
N,K = map(int,input().split())
XYC = [tuple(map(int,input().split())) for i in range(N)]

from math import hypot,acos,atan2,cos,sin
def circles_cross_points(x1,y1,r1,x2,y2,r2):
    d = hypot(x1-x2, y1-y2)
    if r1 + r2 < d or abs(r1 - r2) >= d: return []
    x = (r1**2 + d**2 - r2**2) / (2*r1*d)
    if not -1 <= x <= 1: return []
    a = acos(x)
    t = atan2(y2-y1, x2-x1)
    return [
        (x1+cos(t+a)*r1, y1+sin(t+a)*r1),
        (x1+cos(t-a)*r1, y1+sin(t-a)*r1)
    ]

eps = 10e-10
def is_ok(t):
    cands = []
    for x,y,_ in XYC:
        cands.append((x,y))
    for i,(x1,y1,c1) in enumerate(XYC[:-1]):
        for x2,y2,c2 in XYC[i+1:]:
            ps = circles_cross_points(x1,y1,t/c1,x2,y2,t/c2)
            cands += ps
    for cx,cy in cands:
        k = 0
        for x,y,c in XYC:
            d = hypot(cx-x,cy-y)
            if c*d <= t + eps:
                k += 1
                if k >= K:
                    return True
    return False

ok = 10**10
ng = 0
for _ in range(100):
    m = (ok+ng)/2
    if is_ok(m):
        ok = m
    else:
        ng = m
    if ok-ng < 10e-7: break
print(ok)

Solution (Python):


n,k = map(int, input().split( ))
m = [tuple(map(int, input().split( ))) for i in range(n)]

mx = 10**15
mn = 0
from math import sqrt
def solve(x1, y1, r1, x2, y2, r2):
    rr0 = (x2 - x1)**2 + (y2 - y1)**2
    xd = x2 - x1
    yd = y2 - y1
    rr1 = r1**2; rr2 = r2**2
    cv = (rr0 + rr1 - rr2)
    if max(r1,r2,sqrt(rr0))*2>r1+r2+sqrt(rr0):
        return (x1,y1),(x2,y2)
    sv = sqrt(4*rr0*rr1 - cv**2)
    return (
        (x1 + (cv*xd - sv*yd)/(2.*rr0), y1 + (cv*yd + sv*xd)/(2.*rr0)),
        (x1 + (cv*xd + sv*yd)/(2.*rr0), y1 + (cv*yd - sv*xd)/(2.*rr0)),
    )


while mx-mn>10**(-6) and mx-mn>10**(-7)*mx:
    md = (mx+mn)/2
    cnt = 0
    for i in range(n):
        pi0,pi1 = m[i][0],m[i][1]
        tmp = 0
        for l in range(n):
            if m[l][2]*sqrt(((pi0-m[l][0])**2) + ((pi1-m[l][1])**2))<=md+0.000000001:
                tmp += 1
        if cnt<tmp:
            cnt = tmp

    for i in range(n):
        for j in range(i+1,n):

            p = solve(m[i][0],m[i][1],md/m[i][2], m[j][0],m[j][1],md/m[j][2])

            for pi in p:
                tmp = 0
                for l in range(n):
                    if (((pi[0]-m[l][0])**2) + ((pi[1]-m[l][1])**2))**(1/2)<=md/m[l][2]+0.000000001:
                        tmp += 1
                if cnt<tmp:
                    cnt = tmp

    if cnt>=k:
        mx = md
    else:
        mn = md
print(mx)