### BUGGY CODE ###

import sys
sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))
import math
from itertools import combinations
def resolve():
    eps = 1e-7
    N, K = lr()
    ci = [[] for _ in range(N)]
    _r = []
    for i in range(N):
        x, y, c = lr()
        ci[i].extend([x, y])
        _r.append(c)

    l = 0
    r = 10 ** 6
    while l + eps < r:
        T = (l + r) / 2
        rad = [(T/_r[i])**2 for i in range(N)]
        ans = 0
        for i, j in combinations(range(N), 2):
            if ci[i][0] == ci[j][0] and ci[i][1] == ci[j][1]:
                    continue
            xt = ci[j][0]-ci[i][0]
            yt = ci[j][1]-ci[i][1]
            a = (xt**2+yt**2+rad[i]-rad[j])/2
            d = (xt**2+yt**2)*rad[i]-a**2
            if d < eps:
                continue
            x1 = (a*xt+yt*math.sqrt(d))/(xt**2+yt**2)+ci[i][0]
            y1 = (a*yt-xt*math.sqrt(d))/(xt**2+yt**2)+ci[i][1]
            x2 = (a*xt-yt*math.sqrt(d))/(xt**2+yt**2)+ci[i][0]
            y2 = (a*yt+xt*math.sqrt(d))/(xt**2+yt**2)+ci[i][1]
            tmp = 0
            for k in range(N):
                if (ci[k][0]-x1)**2+(ci[k][1]-y1)**2 < rad[k]+eps:
                    tmp += 1
            ans = max(ans, tmp)
            if ans >= K:
                break
            tmp = 0
            for k in range(N):
                if (ci[k][0]-x2)**2+(ci[k][1]-y2)**2 < rad[k]+eps:
                    tmp += 1
            ans = max(ans, tmp)
            if ans >= K:
                break
        for i in range(N):
            tmp = 0
            for j in range(N):
                if (ci[j][0]-ci[i][0])**2+(ci[j][1]-ci[i][1])**2 < rad[j]+eps:
                    tmp += 1
            ans = max(ans, tmp)
            if ans >= K:
                break
        if ans >= K:
            r = T
        else:
            l = T
    print(r)
resolve()

### FIXED CODE ###

import sys
from math import sqrt
from itertools import combinations
def resolve():
    eps = 1e-7
    N, K, *xyc = map(int, sys.stdin.read().split())
    x = xyc[::3]
    y = xyc[1::3]
    ci = list(zip(x, y))
    _r = xyc[2::3]
    l = 0
    r = 10 ** 6
    while l + eps < r:
        T = (l + r) / 2
        rad = [(T/_r[i])**2 for i in range(N)]
        ans = 0
        xys = []
        for i, j in combinations(range(N), 2):
            cx1, cy1 = ci[i]
            cx2, cy2 = ci[j]
            xt = cx2-cx1
            yt = cy2-cy1
            XY = xt**2+yt**2
            a = (XY+rad[i]-rad[j])/2
            d = XY*rad[i]-a**2
            if d < eps:
                continue
            x1 = (a*xt+yt*sqrt(d))/XY+cx1
            y1 = (a*yt-xt*sqrt(d))/XY+cy1
            x2 = (a*xt-yt*sqrt(d))/XY+cx1
            y2 = (a*yt+xt*sqrt(d))/XY+cy1
            xys.append([x1, y1])
            xys.append([x2, y2])
        xys.extend(ci)
        for X, Y in xys:
            tmp = 0
            for (x, y), k in zip(ci, rad):
                if (x-X)**2+(y-Y)**2 < k+eps:
                    tmp += 1
            ans = max(ans, tmp)
            if ans >= K:
                break
        if ans >= K:
            r = T
        else:
            l = T
    print(r)
resolve()