AtCoder Beginner Contest 157 - Yakiniku Optimization Problem

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-----
4 3
-1 0 3
0 0 3
1 0 2
1 1 40

-----Sample Output-----
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.

Source: atcoder | Difficulty: MEDIUM_HARD


Solutions:
import sys
import math
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
EPS = 1e-09

class Vector:
	x = 0
	y = 0

	def __init__(self, x=0, y=0):
		self.x = x
		self.y = y

	def __add__(self, other):
		return self.__class__(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return self.__class__(self.x - other.x, self.y - other.y)

	def __mul__(self, other):
		return self.__class__(self.x * other, self.y * other)

	def sqrtNorm(self):
		return self.x * self.x + self.y * self.y

	def norm(self):
		return math.sqrt(self.sqrtNorm())

class Circle:
	v = Vector()
	r = 0

	def __init__(self, v, r):
		self.v = v
		self.r = r

	def get_intersections(self, c):
		v = c.v - self.v
		l = v.norm()
		if equal(l, 0):
			return []
		if equal(l + self.r + c.r, max(l, self.r, c.r) * 2):
			if equal(l + self.r, c.r):
				return [self.v - v * (self.r / l)]
			else:
				return [self.v + v * (self.r / l)]
		if l + self.r + c.r < max(l, self.r, c.r) * 2:
			return []
		x = (l * l + self.r * self.r - c.r * c.r) / (2 * l)
		y = math.sqrt(self.r * self.r - x * x)
		mid = self.v + v * (x / l)
		rv = Vector(v.y, -v.x)
		return [mid + rv * (y / l), mid - rv * (y / l)]

	def is_inside(self, v):
		return (v - self.v).norm() < self.r + EPS

def equal(a, b):
	return abs(a - b) < EPS

def main():
	(n, k) = map(int, input().split())
	if k == 1:
		print(0)
		return
	cs = [None] * n
	rs = [0] * n
	for i in range(n):
		(x, y, c) = map(int, input().split())
		cs[i] = Circle(Vector(x, y), c)
		rs[i] = c
	l = 0
	r = 400000
	for z in range(100):
		x = (l + r) / 2
		ps = [None] * n
		for i in range(n):
			ps[i] = cs[i].v
		for i in range(n):
			a = cs[i]
			a.r = x / rs[i]
			for j in range(i + 1, n):
				b = cs[j]
				b.r = x / rs[j]
				ps += a.get_intersections(b)
		is_ok = False
		for p in ps:
			cnt = 0
			for i in range(n):
				nc = cs[i]
				nc.r = x / rs[i]
				if nc.is_inside(p):
					cnt += 1
			if cnt >= k:
				is_ok = True
				break
		if is_ok:
			r = x
		else:
			l = x
	print(r)
main()


import sys
INF = 1 << 60
MOD = 10 ** 9 + 7
sys.setrecursionlimit(2147483647)
input = lambda : sys.stdin.readline().rstrip()
from cmath import phase, rect
from math import acos

def resolve():
	(n, k) = map(int, input().split())
	ZC = [None] * n
	for i in range(n):
		(x, y, c) = map(int, input().split())
		ZC[i] = (complex(x, y), c)

	def check(t):
		circle = [(z, t / c) for (z, c) in ZC]
		candidate = [c for (c, r) in circle]
		for (c1, r1) in circle:
			for (c2, r2) in circle:
				if c1 == c2:
					continue
				d = abs(c2 - c1)
				alpha = phase(c2 - c1)
				s = (r1 ** 2 + d ** 2 - r2 ** 2) / (2 * r1 * d)
				if abs(s) >= 1:
					continue
				theta = acos(s)
				candidate.append(c1 + rect(r1, alpha + theta))
				candidate.append(c1 + rect(r1, alpha - theta))
		return any((sum((abs(z - c) <= r + 1e-05 for (c, r) in circle)) >= k for z in candidate))
	l = 0
	r = 1 << 30
	for _ in range(100):
		m = (l + r) / 2
		if check(m):
			r = m
		else:
			l = m
	print(m)
resolve()


import math

def intersectionCC0(x1, y1, r1, r2):
	r = x1 ** 2 + y1 ** 2
	t = (r + r1 ** 2 - r2 ** 2) / (2 * r)
	dd = r1 ** 2 / r - t ** 2
	if -10 ** (-8) < dd < 0:
		dd = 0
	if dd < 0:
		return []
	(x, y) = (t * x1, t * y1)
	if dd == 0:
		return [(x, y)]
	sq = math.sqrt(dd)
	(dx, dy) = (y1 * sq, -x1 * sq)
	return [(x + dx, y + dy), (x - dx, y - dy)]

def intersectionCC(x1, y1, x2, y2, r1, r2):
	return [(x1 + x, y1 + y) for (x, y) in intersectionCC0(x2 - x1, y2 - y1, r1, r2)]

def chk(t):
	L = [a for a in L0]
	for (i, (x1, y1, c1)) in enumerate(X):
		for (x2, y2, c2) in X[:i]:
			L += intersectionCC(x1, y1, x2, y2, t / c1, t / c2)
	for (x0, y0) in L:
		cnt = 0
		for (x, y, c) in X:
			if math.sqrt((x - x0) ** 2 + (y - y0) ** 2) * c <= t + 10 ** (-8):
				cnt += 1
		if cnt >= K:
			return 1
	return 0
(N, K) = map(int, input().split())
X = []
L0 = []
for _ in range(N):
	(x, y, c) = map(int, input().split())
	X.append((x, y, c))
	L0.append((x, y))
(l, r) = (0, 150000)
while (r - l) * (1 << 20) > max(1, l):
	m = (l + r) / 2
	if chk(m):
		r = m
	else:
		l = m
print((l + r) / 2)


import sys
from itertools import combinations
from math import atan2, cos, sin

def apollonius(p1, c1, p2, c2):
	m1 = p1 + (p2 - p1) * c2 / (c1 + c2)
	m2 = p1 + (p2 - p1) * c2 / (c2 - c1)
	m = (m1 + m2) / 2
	r = abs(m1 - m)
	return (m, r)

def apollonius_intersections(p1, c1, p2, c2, p3, c3):
	(m12, r12) = apollonius(p1, c1, p2, c2)
	(m13, r13) = apollonius(p1, c1, p3, c3)
	v = m13 - m12
	d = abs(v)
	if d > r12 + r13 or d < abs(r12 - r13):
		return (None, None)
	theta = atan2(v.imag, v.real)
	xx = (r12 ** 2 - r13 ** 2 + d ** 2) / (2 * d)
	s = (r12 + r13 + d) / 2
	yy = 2 * (s * (s - r12) * (s - r13) * (s - d)) ** 0.5 / d
	st = sin(theta)
	ct = cos(theta)
	e1 = xx * ct - yy * st + (xx * st + yy * ct) * 1j + m12
	e2 = xx * ct + yy * st + (xx * st - yy * ct) * 1j + m12
	t1 = abs(e1 - p1) * c1
	t2 = abs(e2 - p1) * c1
	if t1 < t2:
		return (e1, t1)
	return (e2, t2)

def get_circumscribed_center(p1, p2, p3):
	A = abs(p2 - p3) ** 2
	B = abs(p3 - p1) ** 2
	C = abs(p1 - p2) ** 2
	T = A * (B + C - A)
	U = B * (C + A - B)
	W = C * (A + B - C)
	try:
		return (T * p1 + U * p2 + W * p3) / (T + U + W)
	except:
		return 0j

def solve(n, k, xyc):
	if k == 1:
		return 0
	xxx = xyc[0::3]
	yyy = xyc[1::3]
	ccc = xyc[2::3]
	beefs = [(i, x + y * 1j, c) for (i, (x, y, c)) in enumerate(zip(xxx, yyy, ccc))]
	ans = 1e+18
	for ((i1, p1, c1), (i2, p2, c2)) in combinations(beefs, 2):
		px = p1 + (p2 - p1) * (c2 / (c1 + c2))
		t = abs(px - p1) * c1 + 1e-08
		ok = 0
		ng = []
		for (i, p, c) in beefs:
			if abs(px - p) * c <= t:
				ok += 1
			else:
				ng.append(i)
		if ok >= k:
			ans = min(ans, t)
			continue
		if ans <= t:
			continue
		for i3 in ng:
			if i3 < i2:
				continue
			(_, p3, c3) = beefs[i3]
			if c1 == c2:
				if c2 == c3:
					e = get_circumscribed_center(p1, p2, p3)
					t = abs(e - p1) * c1
				else:
					(e, t) = apollonius_intersections(p3, c3, p1, c1, p2, c2)
			elif c1 == c3:
				(e, t) = apollonius_intersections(p2, c2, p1, c1, p3, c3)
			else:
				(e, t) = apollonius_intersections(p1, c1, p2, c2, p3, c3)
			if e is None:
				continue
			t += 1e-08
			ok2 = 0
			for (i, p, c) in beefs:
				if abs(e - p) * c <= t:
					ok2 += 1
			if ok2 >= k:
				ans = min(ans, t)
	return ans
(n, k) = map(int, input().split())
xyc = list(map(int, sys.stdin.read().split()))
print(solve(n, k, xyc))


import cmath
EPS = 1e-08
(n, k) = map(int, input().split())
d = []
for _ in range(n):
	(x, y, c) = list(map(int, input().split()))
	d.append((complex(x, y), c))
(ok, ng) = (10 ** 6, 0)
for _ in range(60):
	t = (ok + ng) / 2
	res = 1
	for i in range(n):
		(o1, r1) = (d[i][0], t / d[i][1])
		cnt0 = 1
		for j in range(n):
			if j == i:
				continue
			(o2, r2) = (d[j][0], t / d[j][1])
			if abs(o1 - o2) + EPS <= r2:
				cnt0 += 1
		res = max(res, cnt0)
		for j in range(i + 1, n):
			(o2, r2) = (d[j][0], t / d[j][1])
			if abs(o1 - o2) - EPS >= r1 + r2:
				continue
			elif abs(o1 - o2) + min(r1, r2) + EPS <= max(r1, r2):
				continue
			else:
				co = (r1 ** 2 - r2 ** 2 + abs(o1 - o2) ** 2) / (2 * abs(o1 - o2) * r1)
				si = cmath.sqrt(1 - co ** 2)
				p1 = o1 + (o2 - o1) * (co + 1j * si) * r1 / abs(o1 - o2)
				p2 = o1 + (o2 - o1) * (co - 1j * si) * r1 / abs(o1 - o2)
			(cnt1, cnt2) = (2, 2)
			for l in range(n):
				if l == i or l == j:
					continue
				else:
					(o3, r3) = (d[l][0], t / d[l][1])
					if abs(p1 - o3) + EPS <= r3:
						cnt1 += 1
					if abs(p2 - o3) + EPS <= r3:
						cnt2 += 1
			res = max(res, cnt1, cnt2)
	if res >= k:
		ok = t
	else:
		ng = t
if ok < 1e-06:
	print(0)
else:
	print(ok)


import sys
input = sys.stdin.readline

class Vec:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __str__(self):
		return '({}, {})'.format(self.x, self.y)

	def __add__(self, other):
		return Vec(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Vec(self.x - other.x, self.y - other.y)

	def __mul__(self, k):
		return Vec(self.x * k, self.y * k)

	def __truediv__(self, k):
		return Vec(self.x / k, self.y / k)

	def abs(self):
		return (self.x ** 2 + self.y ** 2) ** 0.5

def dist(p, q):
	return (p - q).abs()

def intersection_circles(c1, r1, c2, r2):
	d = (c1 - c2).abs()
	if r1 + r2 < d:
		return []
	if d < abs(r2 - r1):
		return []
	x = (r1 ** 2 - r2 ** 2 + d ** 2) / (2 * d)
	y = (r1 ** 2 - x ** 2) ** 0.5
	e1 = (c2 - c1) / (c2 - c1).abs()
	e2 = Vec(-e1.y, e1.x)
	p1 = c1 + e1 * x + e2 * y
	p2 = c1 + e1 * x - e2 * y
	return [p1, p2]
(N, K) = map(int, input().split())
center = [None] * N
cost = [0] * N
for i in range(N):
	(x, y, c) = map(int, input().split())
	center[i] = Vec(x, y)
	cost[i] = c
lb = 0
ub = 10 ** 6
EPS = 10 ** (-8)
while ub - lb > EPS:
	mid = (lb + ub) / 2
	r = [mid / c for c in cost]
	points = list(center)
	for i in range(N - 1):
		for j in range(i + 1, N):
			points += intersection_circles(center[i], r[i], center[j], r[j])
	cnt = 0
	for p in points:
		tmp = 0
		for i in range(N):
			if dist(p, center[i]) < r[i] + EPS:
				tmp += 1
		cnt = max(cnt, tmp)
	if cnt >= K:
		ub = mid
	else:
		lb = mid
print(lb)


import sys
input = sys.stdin.buffer.readline
import math
EPS = 10 ** (-7)

class P2:

	def __init__(self, x, y):
		self.x = x
		self.y = y
		self.norm2 = (self.x ** 2 + self.y ** 2) ** 0.5

	def __add__(self, other):
		return P2(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return P2(self.x - other.x, self.y - other.y)

	def smul(self, a):
		return P2(self.x * a, self.y * a)

	def dot(self, other):
		return self.x * other.x + self.y * other.y

	def det(self, other):
		return self.x * other.y - self.y * other.x
(n, k) = map(int, input().split())
p = []
c = []
for _ in range(n):
	(x, y, cc) = map(float, input().split())
	p.append(P2(x, y))
	c.append(cc)
dist = [[(p[i] - p[j]).norm2 for j in range(n)] for i in range(n)]

def check(r):
	r_c = tuple((r / c[i] for i in range(n)))
	cand = [pi for pi in p]
	for i in range(n - 1):
		for j in range(i + 1, n):
			d_ij = p[i] - p[j]
			if dist[i][j] < r_c[i] + r_c[j] - EPS:
				x = (r_c[j] ** 2 - r_c[i] ** 2 + d_ij.norm2 ** 2) / (2 * d_ij.norm2)
				h = math.sqrt(max(r_c[j] ** 2 - x ** 2, 0.0))
				v = P2(-d_ij.y, d_ij.x).smul(h / d_ij.norm2)
				dx = p[j] + d_ij.smul(x / d_ij.norm2)
				cand.append(dx + v)
				cand.append(dx - v)
	for cand_p in cand:
		cnt = 0
		for i in range(n):
			if (p[i] - cand_p).norm2 < r_c[i] + EPS:
				cnt += 1
				if cnt >= k:
					return True
	return False
lb = 0.0
ub = 3000 * 100
while ub - lb > EPS:
	mid = (ub + lb) / 2
	if check(mid):
		ub = mid
	else:
		lb = mid
print(ub)


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)


from math import atan2, cos, sin
EPS = 1e-07

def hypot(a):
	return sum((x ** 2 for x in a)) ** 0.5

def dot(a, b):
	return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]

def add(a, b):
	return [a[0] + b[0], a[1] + b[1], a[2] + b[2]]

def sub(a, b):
	return [a[0] - b[0], a[1] - b[1], a[2] - b[2]]

def matmul(mat, v):
	return [dot(row, v) for row in mat]

def rotZ(theta):
	return [[cos(theta), -sin(theta), 0], [sin(theta), cos(theta), 0], [0, 0, 1]]

def _circleCircleIntersection(R, d, r):
	if d == 0:
		return [(0, 0)]
	x = (R ** 2 - r ** 2 + d ** 2) / (2 * d)
	ySq = R ** 2 - x ** 2
	if ySq == 0:
		return [(x, 0)]
	elif ySq > 0:
		y = ySq ** 0.5
		return [(x, y), (x, -y)]
	else:
		raise AssertionError()

def circleCircleIntersection(x1, y1, r1, x2, y2, r2):
	v1 = [x1, y1, 0]
	v2 = [x2, y2, 0]
	d = hypot(sub(v2, v1))
	if r1 + r2 < d:
		return []
	if min(r1, r2) + d < max(r1, r2):
		return []
	offset = list(v1)
	v1 = sub(v1, offset)
	v2 = sub(v2, offset)
	assert v1[0] == 0 and v1[1] == 0
	angle = -atan2(v2[1], v2[0])
	v2 = matmul(rotZ(angle), v2)
	assert abs(v2[1]) < EPS
	ret = []
	for pt in _circleCircleIntersection(r1, v2[0], r2):
		pt = [pt[0], pt[1], 0]
		pt = matmul(rotZ(-angle), pt)
		pt = add(pt, offset)
		ret.append((pt[0], pt[1]))
	return ret
(N, K) = list(map(int, input().split()))
XYC = []
for i in range(N):
	XYC.append(list(map(int, input().split())))

def numMeat(t):
	intersect = []
	for i in range(len(XYC)):
		(x1, y1, c1) = XYC[i]
		r1 = t / c1
		for j in range(i + 1, len(XYC)):
			(x2, y2, c2) = XYC[j]
			r2 = t / c2
			pts = circleCircleIntersection(x1, y1, r1, x2, y2, r2)
			intersect.extend(pts)
		intersect.append((x1, y1))
	best = 0
	for pt in intersect:
		count = 0
		for (x, y, c) in XYC:
			if c * ((x - pt[0]) ** 2 + (y - pt[1]) ** 2) ** 0.5 <= t + EPS:
				count += 1
		best = max(best, count)
	return best
lo = 0
hi = max((c * (x ** 2 + y ** 2) ** 0.5 for (x, y, c) in XYC))
while hi - lo > EPS:
	mid = (hi + lo) / 2
	if numMeat(mid) >= K:
		hi = mid
	else:
		lo = mid
print(hi)


import sys
import math
eps = 10 ** (-9)

def main():
	input = sys.stdin.readline
	(N, K) = map(int, input().split())
	circles = []
	C = []
	for _ in range(N):
		(x, y, c) = map(int, input().split())
		circles.append(Circle(Vector(x, y), c))
		C.append(c)

	def calc_meet(t):
		candidates = []
		for i in range(N):
			candidates.append(circles[i].c)
			circles[i].r = t / C[i]
			for j in range(i + 1, N):
				circles[j].r = t / C[j]
				candidates += circles[i].cp(circles[j])
		m = 0
		for c in candidates:
			count = 0
			for (i, meet) in enumerate(circles):
				if (c - meet.c).length() * C[i] <= t + eps:
					count += 1
			m = max(m, count)
		return m
	under = 0
	r = 10 ** 6
	while r - under > 10 ** (-6):
		m = (r + under) / 2
		if calc_meet(m) >= K:
			r = m
		else:
			under = m
	print(r)

class Circle:

	def __init__(self, c, r):
		(self.c, self.r) = (c, r)

	def cp(self, other):
		v = other.c - self.c
		d = v.length()
		equal = lambda x, y: abs(x - y) < eps
		if equal(d, 0):
			return []
		if equal(sum([d, self.r, other.r]), 2 * max(d, self.r, other.r)):
			return [self.c + v * (self.r / d)]
		if sum([d, self.r, other.r]) < 2 * max(d, self.r, other.r):
			return []
		x = (d * d + self.r * self.r - other.r * other.r) / (2 * d)
		h = math.sqrt(self.r * self.r - x * x)
		m = self.c + v * (x / d)
		return [m + v.rotate90() * (h / d), m - v.rotate90() * (h / d)]

class Vector:

	def __init__(self, x, y):
		(self.x, self.y) = (x, y)

	def length(self):
		return math.sqrt(self.x * self.x + self.y * self.y)

	def rotate90(self):
		return Vector(self.y, -self.x)

	def __iadd__(self, other):
		self.x += other.x
		self.y += other.y
		return self

	def __add__(self, other):
		new_obj = Vector(self.x, self.y)
		new_obj += other
		return new_obj
	__radd__ = __add__

	def __isub__(self, other):
		self.x -= other.x
		self.y -= other.y
		return self

	def __sub__(self, other):
		new_obj = Vector(self.x, self.y)
		new_obj -= other
		return new_obj

	def __imul__(self, other_scalar):
		self.x *= other_scalar
		self.y *= other_scalar
		return self

	def __mul__(self, other_scalar):
		new_obj = Vector(self.x, self.y)
		new_obj *= other_scalar
		return new_obj
main()


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

def II():
	return int(sys.stdin.readline())

def MI():
	return map(int, sys.stdin.readline().split())

def LI():
	return list(map(int, sys.stdin.readline().split()))

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]

class Vector:

	def __init__(self, x, y):
		(self.x, self.y) = (x, y)
		self.sqrnorm = pow(self.x, 2) + pow(self.y, 2)
		self.norm = self.sqrnorm ** 0.5

	def __add__(self, other):
		return Vector(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return Vector(self.x - other.x, self.y - other.y)

	def __mul__(self, other):
		return Vector(self.x * other, self.y * other)
	__rmul__ = __mul__

class Circle:

	def __init__(self, ox, oy, r):
		(self.o, self.r) = (Vector(ox, oy), r)

def rot90(v):
	return Vector(-v.y, v.x)

def comv(c1, c2):
	if c1.r < c2.r:
		(c1, c2) = (c2, c1)
	(r1, o1) = (c1.r, c1.o)
	(r2, o2) = (c2.r, c2.o)
	d = (o1 - o2).norm
	(s, mx) = (r1 + r2 + d, max(r1, r2, d))
	if s + eps < 2 * mx:
		return []
	elif s > 2 * mx:
		a = (r1 * r1 - r2 * r2 + d * d) / d / 2
		h = (r1 * r1 - a * a) ** 0.5
		o2o1 = o2 - o1
		v1 = o1 + o2o1 * (a / d) + rot90(o2o1) * (h / d)
		v2 = o1 + o2o1 * (a / d) - rot90(o2o1) * (h / d)
		return [v1, v2]
	else:
		return [(o2 - o1) * (r1 / d)]

def isinside(c, v):
	return (c.o - v).norm <= c.r + eps
eps = 10 ** (-7)

def main():

	def ok(t):
		cc = []
		vv = []
		for (x, y, c) in xyc:
			cc.append(Circle(x, y, t / c))
			vv.append(Vector(x, y))
		for j in range(n):
			for i in range(j):
				vv += comv(cc[i], cc[j])
		for v in vv:
			cnt = 0
			for c in cc:
				if isinside(c, v):
					cnt += 1
				if cnt == k:
					return True
		return False
	(n, k) = MI()
	xyc = LLI(n)
	(l, r) = (0, 200000)
	for _ in range(50):
		t = (l + r) / 2
		if ok(t):
			r = t
		else:
			l = t
	print(t)
main()


import math
(n, k) = map(int, input().split())
xyc = []
for _ in range(n):
	(x, y, c) = map(int, input().split())
	xyc.append((x, y, c))
if k == 1:
	print(0)
	exit()

def get_intersecs(x0, y0, r0, x1, y1, r1):
	d = math.sqrt((x1 - x0) ** 2 + (y1 - y0) ** 2)
	if d > r0 + r1:
		return []
	if d < abs(r0 - r1):
		return []
	if d == 0 and r0 == r1:
		return []
	else:
		a = (r0 ** 2 - r1 ** 2 + d ** 2) / (2 * d)
		if r0 < a:
			return []
		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
		x4 = x2 - h * (y1 - y0) / d
		y4 = y2 + h * (x1 - x0) / d
		return [(x3, y3), (x4, y4)]

def calc(x1, y1, x2, y2, c2):
	return c2 * math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)

def count(x, y, t):
	cnt = 0
	for i in range(n):
		(xi, yi, ci) = xyc[i]
		if calc(x, y, xi, yi, ci) < t + 1e-07:
			cnt += 1
			if cnt >= k:
				return cnt
	return cnt

def check(t):
	for i in range(n):
		(x, y, _) = xyc[i]
		if count(x, y, t) >= k:
			return True
	for i in range(n - 1):
		for j in range(i + 1, n):
			(x1, y1, c1) = xyc[i]
			(x2, y2, c2) = xyc[j]
			intersecs = get_intersecs(x1, y1, t / c1, x2, y2, t / c2)
			for (x, y) in intersecs:
				if count(x, y, t) >= k:
					return True
	return False
low = 0
high = 10 ** 7
for _ in range(100):
	mid = (high + low) / 2
	if check(mid):
		high = mid
	else:
		low = mid
print((high + low) / 2)


import sys
from math import sqrt
from itertools import combinations

def resolve():
	eps = 1e-07
	(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()


from math import hypot

def solve():
	(N, K) = list(map(int, input().split()))
	(xs, ys, cs) = ([], [], [])
	for _ in range(N):
		(x, y, c) = list(map(int, input().split()))
		xs.append(x)
		ys.append(y)
		cs.append(c)
	EPS = 10 ** (-10)

	def isLE(a, b):
		return not a > b + EPS

	def getIntersectionLCs(a, b, c, xC, yC, r):
		e = a * xC + b * yC + c
		ab2 = a ** 2 + b ** 2
		v = r ** 2 * ab2 - e ** 2
		if v < 0:
			return []
		elif v == 0:
			xP = xC + -a * e / ab2
			yP = yC + -b * e / ab2
			return [(xP, yP)]
		else:
			v = v ** 0.5
			(ae, be) = (a * e, b * e)
			(av, bv) = (a * v, b * v)
			xP1 = xC + (-ae + bv) / ab2
			yP1 = yC + (-be - av) / ab2
			xP2 = xC + (-ae - bv) / ab2
			yP2 = yC + (-be + av) / ab2
			return [(xP1, yP1), (xP2, yP2)]

	def getIntersectionCCs(x1, y1, r1, x2, y2, r2):
		(xC, yC) = (x2 - x1, y2 - y1)
		c = -(xC ** 2 + yC ** 2 + r1 ** 2 - r2 ** 2) / 2
		intCCs = getIntersectionLCs(xC, yC, c, 0, 0, r1)
		intCCs = [(x1 + x, y1 + y) for (x, y) in intCCs]
		return intCCs

	def countNum(xP, yP, xs, ys, rs, K):
		num = 0
		for (i, (x, y, r)) in enumerate(zip(xs, ys, rs), start=1):
			dist = hypot(x - xP, y - yP)
			if isLE(dist, r):
				num += 1
			if num >= K:
				return True
			elif num + N - i < K:
				return False
		return num >= K

	def isOK(t):
		rs = [t / c for c in cs]
		for (xP, yP) in zip(xs, ys):
			if countNum(xP, yP, xs, ys, rs, K):
				return True
		for i in range(N):
			(x1, y1, r1) = (xs[i], ys[i], rs[i])
			for j in range(i + 1, N):
				(x2, y2, r2) = (xs[j], ys[j], rs[j])
				intCCs = getIntersectionCCs(x1, y1, r1, x2, y2, r2)
				for (xP, yP) in intCCs:
					if countNum(xP, yP, xs, ys, rs, K):
						return True
		return False
	(ng, ok) = (0, 2 * 10 ** 5)
	while abs(ok - ng) > 10 ** (-7):
		mid = (ng + ok) / 2
		if isOK(mid):
			ok = mid
		else:
			ng = mid
	print(ok)
solve()


from math import sqrt, fabs

class Circle:

	def __init__(self, x, y, r):
		self.x = x
		self.y = y
		self.r = r
		self.eps = 1e-08

	def contain(self, x, y):
		d2 = (self.x - x) ** 2 + (self.y - y) ** 2
		return d2 <= self.r ** 2 + self.eps

	def intersect(self, other):
		eps = self.eps
		if self.r > other.r:
			(x1, y1, R) = (self.x, self.y, self.r)
			(x2, y2, r) = (other.x, other.y, other.r)
		else:
			(x1, y1, R) = (other.x, other.y, other.r)
			(x2, y2, r) = (self.x, self.y, self.r)
		d = sqrt((x1 - x2) ** 2 + (y1 - y2) ** 2)
		if fabs(d) < eps and fabs(R - r) < eps:
			return ('相同', None)
		if fabs(d - (R - r)) < eps:
			x3 = (R * x2 - r * x1) / (R - r)
			y3 = (R * y2 - r * y1) / (R - r)
			return ('內切', [(x3, y3)])
		if fabs(d - (R + r)) < eps:
			x3 = (R * x1 + r * x2) / (R + r)
			y3 = (R * y1 + r * y2) / (R + r)
			return ('外切', [(x3, y3)])
		if d < R - r + eps:
			return ('內離', None)
		if d > R + r + eps:
			return ('外離', None)
		a = (R ** 2 - r ** 2 + d ** 2) / (2 * d)
		h = sqrt(R ** 2 - a ** 2)
		cx = x1 + a * (x2 - x1) / d
		cy = y1 + a * (y2 - y1) / d
		x3 = cx + h * (y2 - y1) / d
		y3 = cy - h * (x2 - x1) / d
		x4 = cx - h * (y2 - y1) / d
		y4 = cy + h * (x2 - x1) / d
		return ('相交', [(x3, y3), (x4, y4)])
(N, K) = map(int, input().split())
(X, Y, C) = ([], [], [])
for _ in range(N):
	(x, y, c) = map(int, input().split())
	X.append(x)
	Y.append(y)
	C.append(c)

def check(t):
	circles = [Circle(x, y, t / c) for (x, y, c) in zip(X, Y, C)]
	cands = []
	for i in range(N):
		cands.append((X[i], Y[i]))
		for j in range(i + 1, N):
			(kind, points) = circles[i].intersect(circles[j])
			if kind in ['相交', '內切', '外切']:
				cands.extend(points)
	for (x, y) in cands:
		cnt = sum((1 for circle in circles if circle.contain(x, y)))
		if cnt >= K:
			return True
	return False
(lb, ub) = (0, 1000000000.0)
for _ in range(100):
	mid = (lb + ub) / 2
	if check(mid):
		ub = mid
	else:
		lb = mid
print(ub)


(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-08
(ng, ok) = (0, 10 ** 6)
while ok - ng > eps:
	n = (ng + ok) / 2
	if check(n):
		ok = n
	else:
		ng = n
print(ok)


def main():
	import sys
	sys.setrecursionlimit(10 ** 9)
	input = sys.stdin.readline
	from math import hypot
	from collections import deque
	(N, K) = map(int, input().split())
	XYC = [tuple(map(int, input().split())) for _ in range(N)]
	dq = deque([(0, 0, 1000.0)])
	ans = 10 ** 18
	while dq:
		(X, Y, r) = dq.popleft()
		c_hypot = [c * hypot(max(abs(X - x) - r, 0), max(abs(Y - y) - r, 0)) for (x, y, c) in XYC]
		c_hypot.sort()
		if ans * 0.9999995 > c_hypot[K - 1]:
			c_hypot = [c * hypot(X - x, Y - y) for (x, y, c) in XYC]
			c_hypot.sort()
			if c_hypot[K - 1] < ans:
				ans = c_hypot[K - 1]
			r /= 2
			dq += [(X + r, Y + r, r), (X - r, Y + r, r), (X + r, Y - r, r), (X - r, Y - r, r)]
	print(ans)
main()


from math import atan2, cos, sin
EPS = 1e-07

def hypot(a):
	return sum((x ** 2 for x in a)) ** 0.5

def scale(s, v):
	assert isinstance(s, int) or isinstance(s, float)
	return [s * v[0], s * v[1], s * v[2]]

def dot(a, b):
	return a[0] * b[0] + a[1] * b[1] + a[2] * b[2]

def add(a, b):
	return [a[0] + b[0], a[1] + b[1], a[2] + b[2]]

def sub(a, b):
	return [a[0] - b[0], a[1] - b[1], a[2] - b[2]]

def matmul(mat, v):
	return [dot(row, v) for row in mat]

def rotZ(theta):
	return [[cos(theta), -sin(theta), 0], [sin(theta), cos(theta), 0], [0, 0, 1]]

def _circleCircleIntersection(R, d, r):
	if d == 0:
		return [(0, 0)]
	x = (R ** 2 - r ** 2 + d ** 2) / (2 * d)
	ySq = R ** 2 - x ** 2
	if ySq == 0:
		return [(x, 0)]
	elif ySq > 0:
		y = ySq ** 0.5
		return [(x, y), (x, -y)]
	else:
		raise AssertionError()

def circleCircleIntersection(x1, y1, r1, x2, y2, r2):
	v1 = [x1, y1, 0]
	v2 = [x2, y2, 0]
	d = hypot(sub(v2, v1))
	if r1 + r2 < d:
		return []
	if min(r1, r2) + d < max(r1, r2):
		return []
	offset = list(v1)
	v1 = sub(v1, offset)
	v2 = sub(v2, offset)
	assert v1[0] == 0 and v1[1] == 0
	angle = -atan2(v2[1], v2[0])
	v2 = matmul(rotZ(angle), v2)
	assert abs(v2[1]) < EPS
	ret = []
	for pt in _circleCircleIntersection(r1, v2[0], r2):
		pt = [pt[0], pt[1], 0]
		pt = matmul(rotZ(-angle), pt)
		pt = add(pt, offset)
		ret.append((pt[0], pt[1]))
	return ret

def circleCircleIntersection(x1, y1, r1, x2, y2, r2):
	v1 = [x1, y1, 0]
	v2 = [x2, y2, 0]
	d = hypot(sub(v2, v1))
	if r1 + r2 < d:
		return []
	if min(r1, r2) + d < max(r1, r2):
		return []
	if d == 0:
		return [(x1, y1)]
	u = scale(1 / d, sub(v2, v1))
	a = (r1 ** 2 - r2 ** 2 + d ** 2) / (2 * d)
	mid = add(v1, scale(a, u))
	uPerpendicular = [u[1], -u[0], 0]
	h = (r1 ** 2 - a ** 2) ** 0.5
	ret1 = add(mid, scale(h, uPerpendicular))
	ret2 = add(mid, scale(-h, uPerpendicular))
	return [[ret1[0], ret1[1]], [ret2[0], ret2[1]]]
(N, K) = list(map(int, input().split()))
XYC = []
for i in range(N):
	XYC.append(list(map(int, input().split())))

def numMeat(t):
	intersect = []
	for i in range(len(XYC)):
		(x1, y1, c1) = XYC[i]
		r1 = t / c1
		for j in range(i + 1, len(XYC)):
			(x2, y2, c2) = XYC[j]
			r2 = t / c2
			pts = circleCircleIntersection(x1, y1, r1, x2, y2, r2)
			intersect.extend(pts)
		intersect.append((x1, y1))
	if False:
		import matplotlib.pyplot as plt
		plt.figure()
		ax = plt.gca()
		ax.cla()
		bound = t // 5
		ax.set_xlim((-bound, bound))
		ax.set_ylim((-bound, bound))
		for i in range(len(XYC)):
			(x1, y1, c1) = XYC[i]
			r1 = t / c1
			ax.add_artist(plt.Circle((x1, y1), r1, color='blue', fill=False))
		for (x, y) in intersect:
			ax.plot([x], [y], '.', color='red')
		plt.show()
	best = 0
	for pt in intersect:
		count = 0
		for (x, y, c) in XYC:
			if c * ((x - pt[0]) ** 2 + (y - pt[1]) ** 2) ** 0.5 <= t + EPS:
				count += 1
		best = max(best, count)
	return best
lo = 0
hi = max((c * (x ** 2 + y ** 2) ** 0.5 for (x, y, c) in XYC))
while hi - lo > EPS:
	mid = (hi + lo) / 2
	if numMeat(mid) >= K:
		hi = mid
	else:
		lo = mid
print(hi)


from math import hypot
from collections import deque
(N, K, *XYC) = map(int, open(0).read().split())
XYC = list(zip(*[iter(XYC)] * 3))
Q = deque([(0, 0, 1000.0)])
ans = float('inf')
while Q:
	(X, Y, r) = Q.popleft()
	if ans * 0.9999995 > sorted((c * hypot(max(abs(X - x) - r, 0), max(abs(Y - y) - r, 0)) for (x, y, c) in XYC))[K - 1]:
		ans = min(ans, sorted((c * hypot(X - x, Y - y) for (x, y, c) in XYC))[K - 1])
		r /= 2
		Q += [(X + r, Y + r, r), (X - r, Y + r, r), (X + r, Y - r, r), (X - r, Y - r, r)]
print(ans)


def wantnum(m):
	plis = []
	for i in range(N):
		plis.append([xyc[i][0], xyc[i][1]])
	for i in range(N):
		for j in range(i):
			xA = xyc[i][0]
			yA = xyc[i][1]
			xB = xyc[j][0]
			yB = xyc[j][1]
			r1 = m / xyc[i][2]
			r2 = m / xyc[j][2]
			X = xB - xA
			Y = yB - yA
			a = (X ** 2 + Y ** 2 + r1 ** 2 - r2 ** 2) / 2
			retx1 = (a * X + Y * ((X ** 2 + Y ** 2) * r1 ** 2 - a ** 2) ** 0.5) / (X ** 2 + Y ** 2)
			rety1 = (a * Y - X * ((X ** 2 + Y ** 2) * r1 ** 2 - a ** 2) ** 0.5) / (X ** 2 + Y ** 2)
			retx1 += xA
			rety1 += yA
			retx2 = (a * X - Y * ((X ** 2 + Y ** 2) * r1 ** 2 - a ** 2) ** 0.5) / (X ** 2 + Y ** 2)
			rety2 = (a * Y + X * ((X ** 2 + Y ** 2) * r1 ** 2 - a ** 2) ** 0.5) / (X ** 2 + Y ** 2)
			retx2 += xA
			rety2 += yA
			if type(retx1) is not complex and type(rety1) is not complex:
				plis.append([retx1, rety1])
			if type(retx2) is not complex and type(rety2) is not complex:
				plis.append([retx2, rety2])
	ans = 0
	for (nx, ny) in plis:
		nnum = 0
		for (i, j, r) in xyc:
			if (i - nx) ** 2 + (j - ny) ** 2 < (m / r) ** 2 + 10 ** (-7):
				nnum += 1
		ans = max(ans, nnum)
	return ans
(N, K) = map(int, input().split())
xyc = []
l = 0
r = 0
for i in range(N):
	(x, y, c) = map(int, input().split())
	xyc.append([x, y, c])
	r = max(r, c * (x ** 2 + y ** 2) ** 0.5)
while r - l > 10 ** (-7) and r - l > l * 10 ** (-7):
	m = (r + l) / 2
	ret = wantnum(m)
	if ret >= K:
		r = m
	else:
		l = m
print(r)


import sys
import cmath
import math
import copy
INF = float('inf')
EPS = 1e-09

def ctc(p1, r1, p2, r2):
	if r2 < r1:
		(p1, p2) = (p2, p1)
		(r1, r2) = (r2, r1)
	d = abs(p1 - p2)
	if p1 == p2 and d < EPS:
		return INF
	elif d - (r2 + r1) > EPS:
		return 4
	elif d - (r2 + r1) > -EPS:
		return 3
	elif d - (r2 - r1) > EPS:
		return 2
	elif d - (r2 - r1) > -EPS:
		return 1
	else:
		return 0

def inner(p1, c1, p2, c2):
	coeff1 = c1 / (c1 + c2)
	coeff2 = c2 / (c1 + c2)
	return p1 * coeff1 + p2 * coeff2

def intersection(p1, r1, p2, r2):
	status = ctc(p1, r1, p2, r2)
	d = abs(p1 - p2)
	if not 1 <= status <= 3:
		return []
	elif status == 3:
		return [inner(p1, r1, p2, r2)]
	elif status == 1:
		return [p1 + r1 * (p1 - p2) / d]
	else:
		if r1 > r2:
			(p1, p2) = (p2, p1)
			(r1, r2) = (r2, r1)
		d = abs(p1 - p2)
		cos = (r1 ** 2 + d ** 2 - r2 ** 2) / (2 * r1 * d)
		angle = math.acos(cos)
		phi = cmath.phase(p2 - p1)
		return [p1 + cmath.rect(r1, phi + angle), p1 + cmath.rect(r1, phi - angle)]

def circle_in(p, o, r1, allow_on_edge=True):
	if allow_on_edge:
		return abs(o - p) - r1 < EPS
	else:
		return abs(o - p) - r1 < -EPS

def solve(N: int, K: int, x: 'List[int]', y: 'List[int]', c: 'List[int]'):
	comp = [complex(xx, yy) for (xx, yy) in zip(x, y)]
	left = 0
	right = 2000 * max(c)
	while right - left > EPS:
		mid = (left + right) / 2
		yakiniku = 0
		b = copy.copy(comp)
		for i in range(N):
			for j in range(i + 1, N):
				b.extend(intersection(comp[i], mid / c[i], comp[j], mid / c[j]))
		for p in b:
			count = [circle_in(p, comp[k], mid / c[k]) for k in range(N)]
			yakiniku = max(yakiniku, sum(count))
		if yakiniku >= K:
			right = mid
		else:
			left = mid
	print(mid)
	return

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	N = int(next(tokens))
	K = int(next(tokens))
	x = [int()] * N
	y = [int()] * N
	c = [int()] * N
	for i in range(N):
		x[i] = int(next(tokens))
		y[i] = int(next(tokens))
		c[i] = int(next(tokens))
	solve(N, K, x, y, c)
main()


import sys
sysread = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)
import math
from itertools import combinations

def run():
	(N, K) = map(int, sysread().split())
	niku = []
	for i in range(N):
		niku.append([i] + list(map(int, sysread().split())))
	high_t = math.sqrt(2000 ** 2 + 2000 ** 2) * 101
	low_t = 0
	current = (high_t + low_t) / 2
	delta = 5e-07
	if K == 1:
		print(0)
		return None
	while high_t - low_t > delta:
		done = False
		c = [(current / ci) ** 2 for (_, _, _, ci) in niku]
		for (i, xi, yi, _) in niku:
			if done:
				break
			K0 = 0
			for (k, xk, yk, _) in niku:
				if done:
					break
				ck = c[k]
				if (xi - xk) ** 2 + (yi - yk) ** 2 <= ck + delta:
					K0 += 1
				if K0 >= K:
					done = True
		for ((i, xi, yi, _), (j, xj, yj, _)) in combinations(niku, 2):
			if done:
				break
			(ci, cj) = (c[i], c[j])
			xj -= xi
			yj -= yi
			d2 = xj ** 2 + yj ** 2
			d = math.sqrt(d2)
			x = (d2 + ci - cj) / (2 * d)
			e = ci - x ** 2
			if e < 0 or math.sqrt(ci) + math.sqrt(cj) < d:
				continue
			else:
				e = math.sqrt(e)
			(vx1, vy1) = (xj / d, yj / d)
			(vx2, vy2) = (yj / d, -xj / d)
			X1 = vx1 * x + vx2 * e + xi
			X2 = vx1 * x - vx2 * e + xi
			Y1 = vy1 * x + vy2 * e + yi
			Y2 = vy1 * x - vy2 * e + yi
			K1 = 0
			K2 = 0
			for (k, xk, yk, _) in niku:
				if done:
					break
				ck = c[k]
				if (xk - X1) ** 2 + (yk - Y1) ** 2 <= ck + delta:
					K1 += 1
				if (xk - X2) ** 2 + (yk - Y2) ** 2 <= ck + delta:
					K2 += 1
				if K1 >= K or K2 >= K:
					done = True
		if done:
			high_t = current
			current = (high_t + low_t) / 2
		else:
			low_t = current
			current = (high_t + low_t) / 2
	print((low_t + high_t) / 2)
	return None
run()


import sys
from math import hypot

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

def MAP():
	return map(int, input().split())

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

class Geometry:

	def __init__(self, EPS):
		self.EPS = EPS

	def add(self, a, b):
		(x1, y1) = a
		(x2, y2) = b
		return (x1 + x2, y1 + y2)

	def sub(self, a, b):
		(x1, y1) = a
		(x2, y2) = b
		return (x1 - x2, y1 - y2)

	def mul(self, a, b):
		(x1, y1) = a
		if not isinstance(b, tuple):
			return (x1 * b, y1 * b)
		(x2, y2) = b
		return (x1 * x2, y1 * y2)

	def div(self, a, b):
		(x1, y1) = a
		if not isinstance(b, tuple):
			return (x1 / b, y1 / b)
		(x2, y2) = b
		return (x1 / x2, y1 / y2)

	def abs(self, a):
		from math import hypot
		(x1, y1) = a
		return hypot(x1, y1)

	def norm(self, a):
		(x, y) = a
		return x ** 2 + y ** 2

	def dot(self, a, b):
		(x1, y1) = a
		(x2, y2) = b
		return x1 * x2 + y1 * y2

	def cross(self, a, b):
		(x1, y1) = a
		(x2, y2) = b
		return x1 * y2 - y1 * x2

	def project(self, seg, p):
		(p1, p2) = seg
		base = self.sub(p2, p1)
		r = self.dot(self.sub(p, p1), base) / self.norm(base)
		return self.add(p1, self.mul(base, r))

	def reflect(self, seg, p):
		return self.add(p, self.mul(self.sub(self.project(seg, p), p), 2))

	def ccw(self, p0, p1, p2):
		a = self.sub(p1, p0)
		b = self.sub(p2, p0)
		if self.cross(a, b) > self.EPS:
			return 1
		if self.cross(a, b) < -self.EPS:
			return -1
		if self.dot(a, b) < -self.EPS:
			return 2
		if self.norm(a) < self.norm(b):
			return -2
		return 0

	def intersect(self, seg1, seg2):
		(p1, p2) = seg1
		(p3, p4) = seg2
		return self.ccw(p1, p2, p3) * self.ccw(p1, p2, p4) <= 0 and self.ccw(p3, p4, p1) * self.ccw(p3, p4, p2) <= 0

	def get_distance_LP(self, line, p):
		(p1, p2) = line
		return abs(self.cross(self.sub(p2, p1), self.sub(p, p1)) / self.abs(self.sub(p2, p1)))

	def get_distance_SP(self, seg, p):
		(p1, p2) = seg
		if self.dot(self.sub(p2, p1), self.sub(p, p1)) < 0:
			return self.abs(self.sub(p, p1))
		if self.dot(self.sub(p1, p2), self.sub(p, p2)) < 0:
			return self.abs(self.sub(p, p2))
		return self.get_distance_LP(seg, p)

	def get_distance_SS(self, seg1, seg2):
		(p1, p2) = seg1
		(p3, p4) = seg2
		if self.intersect(seg1, seg2):
			return 0
		return min(self.get_distance_SP(seg1, p3), self.get_distance_SP(seg1, p4), self.get_distance_SP(seg2, p1), self.get_distance_SP(seg2, p2))

	def get_cross_pointSS(self, seg1, seg2):
		(p1, p2) = seg1
		(p3, p4) = seg2
		base = self.sub(p4, p3)
		dist1 = abs(self.cross(base, self.sub(p1, p3)))
		dist2 = abs(self.cross(base, self.sub(p2, p3)))
		t = dist1 / (dist1 + dist2)
		return self.add(p1, self.mul(self.sub(p2, p1), t))

	def intersectCL(self, c, line):
		(x, y, r) = c
		return self.get_distance_SP(line, (x, y)) <= r

	def get_cross_pointCL(self, c, line):
		from math import sqrt
		if not self.intersectCL(c, line):
			return -1
		(x, y, r) = c
		(p1, p2) = line
		pr = self.project(line, (x, y))
		e = self.div(self.sub(p2, p1), self.abs(self.sub(p2, p1)))
		base = sqrt(r * r - self.norm(self.sub(pr, (x, y))))
		return [self.add(pr, self.mul(e, base)), self.sub(pr, self.mul(e, base))]

	def arg(self, p):
		from math import atan2
		(x, y) = p
		return atan2(y, x)

	def polar(self, a, r):
		from math import sin, cos
		return (cos(r) * a, sin(r) * a)

	def intersectCC(self, c1, c2):
		from math import hypot
		(x1, y1, r1) = c1
		(x2, y2, r2) = c2
		return hypot(x1 - x2, y1 - y2) <= r1 + r2

	def get_cross_pointCC(self, c1, c2):
		from math import acos
		if not self.intersectCC(c1, c2):
			return -1
		(x1, y1, r1) = c1
		(x2, y2, r2) = c2
		try:
			d = self.abs(self.sub((x1, y1), (x2, y2)))
			a = acos((r1 * r1 + d * d - r2 * r2) / (2 * r1 * d))
			t = self.arg(self.sub((x2, y2), (x1, y1)))
			return [self.add((x1, y1), self.polar(r1, t + a)), self.add((x1, y1), self.polar(r1, t - a))]
		except:
			return -1

def bisearch_min(mn, mx, func, EPS):
	ok = mx
	ng = mn
	while ng + EPS < ok:
		mid = (ok + ng) / 2
		if func(mid):
			ok = mid
		else:
			ng = mid
	return ok
gm = Geometry(10 ** (-8))

def calc(t):
	ccls = []
	XY = []
	for (x, y, c) in XYC:
		XY.append((x, y))
		r = t / c
		ccls.append((x, y, r))
	for i in range(N):
		ccl1 = ccls[i]
		for j in range(i + 1, N):
			ccl2 = ccls[j]
			res = gm.get_cross_pointCC(ccl1, ccl2)
			if res != -1:
				XY.append(res[0])
				XY.append(res[1])
	mx = 0
	for (x, y) in XY:
		cnt = 0
		for (x2, y2, r) in ccls:
			if hypot(x - x2, y - y2) <= r + gm.EPS:
				cnt += 1
		mx = max(mx, cnt)
	return mx >= K
(N, K) = MAP()
XYC = []
for i in range(N):
	(x, y, c) = MAP()
	XYC.append((x, y, c))
res = bisearch_min(0.0, 10 ** 9, calc, 10 ** (-8))
print(res)


def main():
	import sys
	from math import sqrt, hypot
	input = sys.stdin.readline

	def dist(p1, p2):
		return hypot(p1[0] - p2[0], p1[1] - p2[1])

	def CP(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 4 * rr0 * rr1 - cv ** 2 >= 0:
			sv = sqrt(4 * rr0 * rr1 - cv ** 2)
			return ((x1 + (cv * xd - sv * yd) / (2.0 * rr0), y1 + (cv * yd + sv * xd) / (2.0 * rr0)), (x1 + (cv * xd + sv * yd) / (2.0 * rr0), y1 + (cv * yd - sv * xd) / (2.0 * rr0)))
		else:
			return ((x1, y1), (x2, y2))
	(N, K) = map(int, input().split())
	if N == 1:
		print(0)
		exit()
	info = []
	for _ in range(N):
		info.append(tuple(map(int, input().split())))
	eps = 10 ** (-8)
	ok = 150000.0
	ng = -eps
	mid = (ok + ng) / 2
	while ok - ng > 10 ** (-7):
		cp_list = []
		flg = 0
		fin = 0
		for i in range(N):
			(x1, y1, c1) = info[i]
			p1 = (x1, y1)
			r1 = mid / c1
			for j in range(i + 1, N):
				(x2, y2, c2) = info[j]
				p2 = (x2, y2)
				r2 = mid / c2
				(pa, pb) = CP(x1, y1, r1, x2, y2, r2)
				cp_list.append(pa)
				cp_list.append(pb)
		flg = 0
		for p0 in cp_list:
			tmp = 0
			for (x, y, c) in info:
				p = (x, y)
				r = mid / c
				if dist(p0, p) < r + eps:
					tmp += 1
			if tmp >= K:
				flg = 1
				break
		if flg:
			ok = mid
		else:
			ng = mid
		mid = (ok + ng) / 2
	print(ok)
main()


(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.0 * rr0), y1 + (cv * yd + sv * xd) / (2.0 * rr0)), (x1 + (cv * xd + sv * yd) / (2.0 * rr0), y1 + (cv * yd - sv * xd) / (2.0 * 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 + 1e-09:
				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] + 1e-09:
						tmp += 1
				if cnt < tmp:
					cnt = tmp
	if cnt >= k:
		mx = md
	else:
		mn = md
print(mx)


import sys
input = sys.stdin.readline
from math import sqrt
(N, K) = map(int, input().split())
M = [tuple(map(int, input().split())) for i in range(N)]

def cross_coor(x0, y0, c0, x1, y1, c1):
	if (c1 - c0) ** 2 <= (x1 - x0) ** 2 + (y1 - y0) ** 2 <= (c0 + c1) ** 2:
		(x2, y2) = (x1 - x0, y1 - y0)
		a = (x2 ** 2 + y2 ** 2 + c0 ** 2 - c1 ** 2) / 2
		xa = (a * x2 + y2 * sqrt((x2 ** 2 + y2 ** 2) * c0 ** 2 - a ** 2)) / (x2 ** 2 + y2 ** 2) + x0
		ya = (a * y2 - x2 * sqrt((x2 ** 2 + y2 ** 2) * c0 ** 2 - a ** 2)) / (x2 ** 2 + y2 ** 2) + y0
		xb = (a * x2 - y2 * sqrt((x2 ** 2 + y2 ** 2) * c0 ** 2 - a ** 2)) / (x2 ** 2 + y2 ** 2) + x0
		yb = (a * y2 + x2 * sqrt((x2 ** 2 + y2 ** 2) * c0 ** 2 - a ** 2)) / (x2 ** 2 + y2 ** 2) + y0
		return [(xa, ya), (xb, yb)]
	else:
		return False
OK = 1 << 31
NG = 0
while OK - NG > 10 ** (-8):
	mid = (OK + NG) / 2
	CANDI = []
	for i in range(N):
		(x0, y0, c0) = M[i]
		CANDI.append((x0, y0))
		for j in range(i + 1, N):
			(x1, y1, c1) = M[j]
			CR = cross_coor(x0, y0, mid / c0, x1, y1, mid / c1)
			if CR:
				CANDI.extend(CR)
	for (z, w) in CANDI:
		count = 0
		for (x, y, c) in M:
			if c ** 2 * ((x - z) ** 2 + (y - w) ** 2) <= (mid + 10 ** (-8)) ** 2:
				count += 1
		if count >= K:
			OK = mid
			break
	else:
		NG = mid
print((OK + NG) / 2)


from itertools import combinations
EPS = 1e-08
(N, K, *XYC) = map(int, open(0).read().split())
PC = [(complex(x, y), c) for (x, y, c) in zip(*[iter(XYC)] * 3)]

def intersection(A, r, B, s):
	D = B - A
	d = abs(D)
	cos_t = (d * d + r * r - s * s) / (2 * d * r)
	sin_t = max(1 - cos_t * cos_t, 0.0) ** 0.5
	R = r * complex(cos_t, sin_t)
	D /= d
	return (A + D * R, A + D * R.conjugate())

def is_ok(T):
	A = [p for (p, _) in PC]
	for ((p1, c1), (p2, c2)) in combinations(PC, 2):
		A += intersection(p1, T / c1, p2, T / c2)
	for a in A:
		if K <= sum((1 for (p, c) in PC if c * abs(a - p) < T + EPS)):
			return True
	return False
(ng, ok) = (0, 1000000)
for _ in range(100):
	md = (ng + ok) / 2
	if is_ok(md):
		ok = md
	else:
		ng = md
print(ok)


import math
(n, k) = map(int, input().split())
(x, y, c) = zip(*[map(int, input().split()) for _ in range(n)])
que = [(0, 0, 1000)]
res = 1000000000.0
i = 0
while i < len(que):
	(px, py, r) = que[i]
	i += 1
	lb = [c[j] * math.hypot(max(abs(px - x[j]) - r, 0), max(abs(py - y[j]) - r, 0)) for j in range(n)]
	if res * (1 - 5e-07) > sorted(lb)[k - 1]:
		dis = [c[j] * math.hypot(px - x[j], py - y[j]) for j in range(n)]
		res = min(res, sorted(dis)[k - 1])
		for dx in (-0.5, 0.5):
			for dy in (-0.5, 0.5):
				que.append((px + dx * r, py + dy * r, r / 2))
print(res)


import sys
from itertools import combinations
from math import sqrt
read = sys.stdin.read
readline = sys.stdin.readline

def main():
	(N, K, *xyc) = map(int, read().split())
	x = xyc[::3]
	y = xyc[1::3]
	xy = list(zip(x, y))
	c = xyc[2::3]
	left = 0
	right = 10 ** 6
	delta = 0.1 ** 7
	while right - left > delta:
		mid = (left + right) / 2
		intersections = []
		r = [(mid / i) ** 2 for i in c]
		for (i, j) in combinations(range(N), 2):
			(x1, y1) = xy[i]
			(x2, y2) = xy[j]
			X = x2 - x1
			Y = y2 - y1
			XY = X ** 2 + Y ** 2
			r1 = r[i]
			r2 = r[j]
			a = (XY + r1 - r2) / 2
			b = XY * r1 - a ** 2
			if b < delta:
				continue
			b = sqrt(b)
			xi1 = (a * X + Y * b) / XY + x1
			yi1 = (a * Y - X * b) / XY + y1
			xi2 = (a * X - Y * b) / XY + x1
			yi2 = (a * Y + X * b) / XY + y1
			intersections.append((xi1, yi1))
			intersections.append((xi2, yi2))
		intersections.extend(xy)
		cnt = 0
		for (X, Y) in intersections:
			tmp = 0
			for ((i, j), k) in zip(xy, r):
				XY = (X - i) ** 2 + (Y - j) ** 2
				if XY < k + delta:
					tmp += 1
			cnt = max(tmp, cnt)
			if cnt >= K:
				break
		if cnt >= K:
			right = mid
		else:
			left = mid
	print(right)

def __starting_point():
	main()
__starting_point()


EPS = 1e-07
(N, K) = map(int, input().split())
pts = []
Cs = []
for _ in range(N):
	(x, y, c) = map(int, input().split())
	pts.append(x + y * 1j)
	Cs.append(c)
Rs = [0] * N

def cands():
	for i in range(N):
		yield pts[i]
		for j in range(i + 1, N):
			pt = pts[j] - pts[i]
			ab = -2 * pt
			l = ab * ab.conjugate()
			c = pt * pt.conjugate() + Rs[i] - Rs[j]
			d = Rs[i] - c * c / l
			if d.real < 0:
				continue
			m = (d / l) ** 0.5
			off = m * (ab.imag - ab.real * 1j)
			yield (-ab * c / l + off + pts[i])
			yield (-ab * c / l - off + pts[i])

def ok(secs):
	for i in range(N):
		Rs[i] = secs * secs / Cs[i] / Cs[i]
	for cand in cands():
		count = 0
		for (pt, r) in zip(pts, Rs):
			xy = pt - cand
			if (xy * xy.conjugate()).real < r + EPS:
				count += 1
				if count == K:
					return True
	return False
lo = 0
hi = 10000000000.0
for _ in range(100):
	mid = (lo + hi) / 2
	if ok(mid):
		hi = mid
	else:
		lo = mid
print(hi)


def Line_Line(p0x, p0y, p1x, p1y, p2x, p2y, p3x, p3y):
	retx = ((p0y - p2y) * (p0x - p1x) * (p2x - p3x) - p0x * (p2x - p3x) * (p0y - p1y) + p2x * (p2y - p3y) * (p0x - p1x)) / ((p2y - p3y) * (p0x - p1x) - (p2x - p3x) * (p0y - p1y))
	if p0x != p1x:
		rety = (p0y - p1y) * (retx - p0x) / (p0x - p1x) + p0y
	else:
		rety = (p2y - p3y) * (retx - p2x) / (p2x - p3x) + p2y
	return (retx, rety)

def Circle_Line(p0x, p0y, p1x, p1y, cx, cy, cr):
	tan_p = (-p1y + p0y, p1x - p0x)
	(nearestx, nearesty) = Line_Line(p0x, p0y, p1x, p1y, cx, cy, cx + tan_p[0], cy + tan_p[1])
	distance = ((nearestx - cx) ** 2 + (nearesty - cy) ** 2) ** 0.5
	p_e = ((p1x - p0x) / (tan_p[0] ** 2 + tan_p[1] ** 2) ** 0.5, (p1y - p0y) / (tan_p[0] ** 2 + tan_p[1] ** 2) ** 0.5)
	near_to_ret = (cr ** 2 - distance ** 2) ** 0.5
	return [(nearestx + near_to_ret * p_e[0], nearesty + near_to_ret * p_e[1]), (nearestx - near_to_ret * p_e[0], nearesty - near_to_ret * p_e[1])]

def Circle_Circle(c0x, c0y, c0r, c1x, c1y, c1r):
	d = ((c0x - c1x) ** 2 + (c0y - c1y) ** 2) ** 0.5
	if not abs(c0r - c1r) <= d <= c0r + c1r:
		return []
	mid_p = (((c0r ** 2 - c1r ** 2 + d ** 2) * c1x + (c1r ** 2 - c0r ** 2 + d ** 2) * c0x) / (2 * d ** 2), ((c0r ** 2 - c1r ** 2 + d ** 2) * c1y + (c1r ** 2 - c0r ** 2 + d ** 2) * c0y) / (2 * d ** 2))
	vx = c0y - c1y
	vy = c1x - c0x
	return Circle_Line(mid_p[0], mid_p[1], mid_p[0] + vx, mid_p[1] + vy, c0x, c0y, c0r)
import sys
input = sys.stdin.readline
from math import sqrt
eps = 10 ** (-9)
(N, K) = map(int, input().split())
XYC = [list(map(int, input().split())) for _ in range(N)]
l = 0
r = 10 ** 8
while r - l > 1e-08:
	D = (l + r) / 2
	Points = []
	for (i, (x0, y0, c0)) in enumerate(XYC):
		Points.append((x0, y0))
		for (j, (x1, y1, c1)) in enumerate(XYC):
			if i >= j:
				continue
			for (px, py) in Circle_Circle(x0, y0, D / c0, x1, y1, D / c1):
				Points.append((px, py))
	ok = False
	for (px, py) in Points:
		count = 0
		for (x, y, c) in XYC:
			if c * ((x - px) ** 2 + (y - py) ** 2) ** 0.5 <= D + eps:
				count += 1
		if count >= K:
			ok = True
			break
	if ok:
		r = D
	else:
		l = D
print(r)


import math
import itertools

def intersections(T, x1, y1, c1, x2, y2, c2):
	left = (c1 * c2) ** 2 * ((x1 - x2) ** 2 + (y1 - y2) ** 2)
	right = T ** 2 * (c1 + c2) ** 2
	if left > right:
		return list()
	if left == right:
		return [((c1 * x1 + c2 * x2) / (c1 + c2), (c1 * y1 + c2 * y2) / (c1 + c2))]
	(r1, r2) = (T / c1, T / c2)
	p12 = (x2 - x1, y2 - y1)
	coef = (r1 ** 2 + p12[0] ** 2 + p12[1] ** 2 - r2 ** 2) / (2 * (p12[0] ** 2 + p12[1] ** 2))
	p1h = (coef * p12[0], coef * p12[1])
	coef = (r1 ** 2 - p1h[0] ** 2 - p1h[1] ** 2) / (p12[0] ** 2 + p12[1] ** 2)
	coef = math.sqrt(max(0, coef))
	hq1 = (-coef * p12[1], coef * p12[0])
	hq2 = (coef * p12[1], -coef * p12[0])
	return [(x1 + p1h[0] + hq1[0], y1 + p1h[1] + hq1[1]), (x1 + p1h[0] + hq2[0], y1 + p1h[1] + hq2[1])]

def check(T, K, points):
	N = len(points)
	target_points = [(p[0], p[1]) for p in points]
	for pair in itertools.combinations(range(N), 2):
		p1 = points[pair[0]]
		p2 = points[pair[1]]
		target_points += intersections(T, p1[0], p1[1], p1[2], p2[0], p2[1], p2[2])
	for tp in target_points:
		cnt = 0
		for p in points:
			d2 = (tp[0] - p[0]) ** 2 + (tp[1] - p[1]) ** 2
			if d2 <= (T / p[2]) ** 2 + 10 ** (-6):
				cnt += 1
			if cnt >= K:
				return True
	return False

def main():
	eps = 10 ** (-10)
	(N, K) = list(map(int, input().split()))
	points = [list(map(int, input().split())) for _ in range(N)]
	(ng, ok) = (0, 3 * 10 ** 5)
	while ok - ng > eps:
		mid = (ok + ng) / 2
		if check(mid, K, points):
			ok = mid
		else:
			ng = mid
	print(ok)
main()


import sys
stdin = sys.stdin
ns = lambda : stdin.readline().rstrip()
ni = lambda : int(stdin.readline().rstrip())
nm = lambda : map(int, stdin.readline().split())
nl = lambda : list(map(int, stdin.readline().split()))

def intersection(p, q, eps=10 ** (-7)):
	(x1, y1, r1) = p
	(x2, y2, r2) = q
	X = x2 - x1
	Y = y2 - y1
	d = X ** 2 + Y ** 2
	c1 = r1 ** 2
	c2 = r2 ** 2
	rc = (d + c1 - c2) / 2
	rs = d * c1 - rc ** 2
	if rs < eps:
		return list()
	rs **= 0.5
	p1x = x1 + (rc * X + rs * Y) / d
	p1y = y1 + (rc * Y - rs * X) / d
	p2x = x1 + (rc * X + rs * Y) / d
	p2y = y1 + (rc * Y + rs * X) / d
	return [(p1x, p1y), (p2x, p2y)]
eps = 10 ** (-7)
(n, k) = nm()
if k == 1:
	print(0)
	exit(0)
niku = [tuple(nm()) for _ in range(n)]
l = [c * (x ** 2 + y ** 2) ** 0.5 for (x, y, c) in niku]
l.sort()
hi = l[k - 1]
lo = 0
for _ in range(50):
	mid = (hi + lo) / 2
	l = [(x, y, mid / c) for (x, y, c) in niku]
	p = [(x, y) for (x, y, c) in niku]
	for i in range(n - 1):
		for j in range(i + 1, n):
			p.extend(intersection(l[i], l[j]))
	for (x, y) in p:
		f = sum(((v - x) ** 2 + (w - y) ** 2 <= r ** 2 + eps for (v, w, r) in l))
		if f >= k:
			hi = mid
			break
	else:
		lo = mid
print(hi)


import sys
INF = float('inf')
tol = 1e-09

def ctc(x1, y1, r1, x2, y2, r2):
	tol = 1e-09
	if r2 < r1:
		(x1, x2) = (x2, x1)
		(y1, y2) = (y2, y1)
		(r1, r2) = (r2, r1)
	d = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
	if x1 == x2 and y1 == y2 and (d < tol):
		return INF
	elif d - (r2 + r1) > tol:
		return 4
	elif d - (r2 + r1) > -tol:
		return 3
	elif d - (r2 - r1) > tol:
		return 2
	elif d - (r2 - r1) > -tol:
		return 1
	else:
		return 0

def inner(x1, y1, c1, x2, y2, c2):
	coeff1 = c1 / (c1 + c2)
	coeff2 = c2 / (c1 + c2)
	b = (x1 * coeff1 + x2 * coeff2, y1 * coeff1 + y2 * coeff2)
	return b

def intersection(x1, y1, r1, x2, y2, r2):
	status = ctc(x1, y1, r1, x2, y2, r2)
	if not 1 <= status <= 3:
		return []
	elif status == 3:
		return [inner(x1, y1, r1, x2, y2, r2)]
	elif status == 1:
		return [(x1 + r1 * (x1 - x2) / d, y1 + r1 * (y1 - y2) / d)]
	else:
		L = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
		cos = (L ** 2 + r1 ** 2 - r2 ** 2) / (2 * r1 * L)
		e1 = ((x2 - x1) / L, (y2 - y1) / L)
		e2 = (-(y2 - y1) / L, (x2 - x1) / L)
		P1H = (r1 * cos / L * (x2 - x1), r1 * cos / L * (y2 - y1))
		ah = (r1 ** 2 - (r1 * cos) ** 2) ** 0.5
		HA = (e2[0] * ah, e2[1] * ah)
		A = (x1 + P1H[0] + HA[0], y1 + P1H[1] + HA[1])
		B = (x1 + P1H[0] - HA[0], y1 + P1H[1] - HA[1])
		return [A, B]

def circle_in(x, y, x1, y1, r1):
	tol = 1e-09
	L = (x1 - x) ** 2 + (y1 - y) ** 2
	R = r1 ** 2
	LR = L - R
	if LR > tol:
		return False
	elif LR > -tol:
		return True
	else:
		return True

def solve(N: int, K: int, x: 'List[int]', y: 'List[int]', c: 'List[int]'):
	left = 0
	right = 2000 * max(c)
	for _ in range(300):
		if right - left < tol:
			break
		mid = (left + right) / 2
		yakiniku = 0
		for i in range(N):
			for j in range(i + 1, N):
				b = intersection(x[i], y[i], mid / c[i], x[j], y[j], mid / c[j])
				for (xx, yy) in b:
					count = [circle_in(xx, yy, x[k], y[k], mid / c[k]) for k in range(N)]
					if yakiniku < sum(count):
						yakiniku = max(yakiniku, sum(count))
		for i in range(N):
			count = [circle_in(x[i], y[i], x[k], y[k], mid / c[k]) for k in range(N)]
			if yakiniku < sum(count):
				yakiniku = max(yakiniku, sum(count))
		if yakiniku >= K:
			right = mid
		else:
			left = mid
	print(mid)
	return

def main():

	def iterate_tokens():
		for line in sys.stdin:
			for word in line.split():
				yield word
	tokens = iterate_tokens()
	N = int(next(tokens))
	K = int(next(tokens))
	x = [int()] * N
	y = [int()] * N
	c = [int()] * N
	for i in range(N):
		x[i] = int(next(tokens))
		y[i] = int(next(tokens))
		c[i] = int(next(tokens))
	solve(N, K, x, y, c)
main()


import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub
sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2 ** 62 - 1
EPS = 1e-08

def read_int():
	return int(input())

def read_int_n():
	return list(map(int, input().split()))

def read_float():
	return float(input())

def read_float_n():
	return list(map(float, input().split()))

def read_str():
	return input().strip()

def read_str_n():
	return list(map(str, input().split()))

def error_print(*args):
	print(*args, file=sys.stderr)

def mt(f):
	import time

	def wrap(*args, **kwargs):
		s = time.time()
		ret = f(*args, **kwargs)
		e = time.time()
		error_print(e - s, 'sec')
		return ret
	return wrap

class Circle:

	def __init__(self, x, y, r):
		self.x = x
		self.y = y
		self.r = r

	def center(self):
		return Point(self.x, self.y)

	def intersection(self, c):
		d = self.center().distance(c.center())
		if d > self.r + c.r:
			return None
		if d < abs(self.r - c.r):
			return None
		if d == 0 and self.r == c.r:
			return None
		else:
			a = (self.r ** 2 - c.r ** 2 + d ** 2) / (2 * d)
			h = math.sqrt(self.r ** 2 - a ** 2 + sys.float_info.epsilon)
			x2 = self.x + a * (c.x - self.x) / d
			y2 = self.y + a * (c.y - self.y) / d
			x3 = x2 + h * (c.y - self.y) / d
			y3 = y2 - h * (c.x - self.x) / d
			x4 = x2 - h * (c.y - self.y) / d
			y4 = y2 + h * (c.x - self.x) / d
			return (Point(x3, y3), Point(x4, y4))

class Point:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def distance(self, p):
		return math.sqrt((self.x - p.x) ** 2 + (self.y - p.y) ** 2)

class Bisect:

	def __init__(self, func):
		self.__func = func

	def bisect_left(self, x, lo, hi):
		while hi - lo > EPS:
			mid = (lo + hi) / 2
			if self.__func(mid) < x:
				lo = mid
			else:
				hi = mid
		return lo

@mt
def slv(N, K, XYC):

	def f(t):
		cs = []
		for (x, y, c) in XYC:
			cs.append(Circle(x, y, t / c))
		cand = [c.center() for c in cs]
		for (i, j) in combinations(range(N), r=2):
			p = cs[i].intersection(cs[j])
			if p:
				cand.append(p[0])
				cand.append(p[1])
		ans = 0
		for p in cand:
			tmp = 0
			for c in cs:
				d = c.center().distance(p)
				if d - EPS < c.r:
					tmp += 1
			ans = max(ans, tmp)
		return ans
	b = Bisect(f)
	return b.bisect_left(K, 0, 10000000)

def main():
	(N, K) = read_int_n()
	XYC = [read_int_n() for _ in range(N)]
	print(slv(N, K, XYC))
main()


import sys
input = sys.stdin.buffer.readline
import math
from itertools import combinations
EPS = 10 ** (-7)

class P2:

	def __init__(self, x: float, y: float):
		self.x = x
		self.y = y
		self.norm = (self.x ** 2 + self.y ** 2) ** 0.5

	def __add__(self, other):
		return P2(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return P2(self.x - other.x, self.y - other.y)

	def __mul__(self, c: float):
		return P2(self.x * c, self.y * c)

	def __truediv__(self, c: float):
		return P2(self.x / c, self.y / c)

	def __eq__(self, other):
		return abs(self.x - other.x) < EPS and abs(self.y - other.y) < EPS

	def dot(self, other) -> float:
		return self.x * other.x + self.y * other.y

	def det(self, other) -> float:
		return self.x * other.y - self.y * other.x

	def rot90(self):
		return P2(-self.y, self.x)

class Circle:

	def __init__(self, p: P2, r: float):
		self.p = p
		self.r = r

	def contains(self, p: P2, allow_on_edge: bool) -> bool:
		if allow_on_edge:
			return (self.p - p).norm < self.r + EPS
		else:
			return (self.p - p).norm < self.r - EPS

	def cct(self, other) -> int:
		if self.p == other.p:
			if abs(self.r - other.r) < EPS:
				return float('inf')
			else:
				return 0
		d = other.p - self.p
		if d.norm > self.r + other.r + EPS:
			return 4
		elif d.norm > self.r + other.r - EPS:
			return 3
		elif d.norm > abs(self.r - other.r) + EPS:
			return 2
		elif d.norm > abs(self.r - other.r) - EPS:
			return 1
		else:
			return 0

	def intersection_points_with_circle(self, other):
		cct = self.cct(other)
		d = other.p - self.p
		if cct == 1:
			if self.r > other.r:
				return [self.p + d * (self.r / d.norm)]
			else:
				return [self.p - d * (self.r / d.norm)]
		elif cct == 3:
			return [self.p + d * (self.r / d.norm)]
		elif cct == 2:
			x = (self.r ** 2 - other.r ** 2 + d.norm ** 2) / (2 * d.norm)
			h = math.sqrt(max(self.r ** 2 - x ** 2, 0.0))
			v = d.rot90() * (h / d.norm)
			dx = self.p + d * (x / d.norm)
			return [dx + v, dx - v]
		return []
(n, k) = map(int, input().split())
p = []
c = []
for _ in range(n):
	(x, y, cc) = map(float, input().split())
	p.append(P2(x, y))
	c.append(cc)

def check(r):
	circles = [Circle(p[i], r / c[i]) for i in range(n)]
	cand = [pi for pi in p]
	for (c_i, c_j) in combinations(circles, r=2):
		cand_ij = c_i.intersection_points_with_circle(c_j)
		cand.extend(cand_ij)
	for cand_p in cand:
		cnt = 0
		for c_i in circles:
			if (c_i.p - cand_p).norm < c_i.r + EPS:
				cnt += 1
				if cnt >= k:
					return True
	return False
lb = 0.0
ub = 3000 * 100
while ub - lb > EPS:
	mid = (ub + lb) / 2
	if check(mid):
		ub = mid
	else:
		lb = mid
print(ub)


import sys
input = sys.stdin.buffer.readline
import math
from itertools import combinations
EPS = 10 ** (-7)

class P2:

	def __init__(self, x, y):
		self.x = x
		self.y = y
		self.norm2 = (self.x ** 2 + self.y ** 2) ** 0.5

	def __add__(self, other):
		return P2(self.x + other.x, self.y + other.y)

	def __sub__(self, other):
		return P2(self.x - other.x, self.y - other.y)

	def __mul__(self, other: float):
		return P2(self.x * other, self.y * other)

	def __truediv__(self, other: float):
		return P2(self.x / other, self.y / other)

	def dot(self, other):
		return self.x * other.x + self.y * other.y

	def det(self, other):
		return self.x * other.y - self.y * other.x

class Circle:

	def __init__(self, p, r):
		self.p = p
		self.r = r
(n, k) = map(int, input().split())
p = []
c = []
for _ in range(n):
	(x, y, cc) = map(float, input().split())
	p.append(P2(x, y))
	c.append(cc)
dist = [[(p[i] - p[j]).norm2 for j in range(n)] for i in range(n)]

def check(r):
	circles = [Circle(p[i], r / c[i]) for i in range(n)]
	cand = [pi for pi in p]
	for (c_i, c_j) in combinations(circles, r=2):
		d_ij = c_i.p - c_j.p
		if d_ij.norm2 < c_i.r + c_j.r - EPS:
			x = (c_j.r ** 2 - c_i.r ** 2 + d_ij.norm2 ** 2) / (2 * d_ij.norm2)
			h = math.sqrt(max(c_j.r ** 2 - x ** 2, 0.0))
			v = P2(-d_ij.y, d_ij.x) * (h / d_ij.norm2)
			dx = c_j.p + d_ij * (x / d_ij.norm2)
			cand.append(dx + v)
			cand.append(dx - v)
	for cand_p in cand:
		cnt = 0
		for c_i in circles:
			if (c_i.p - cand_p).norm2 < c_i.r + EPS:
				cnt += 1
				if cnt >= k:
					return True
	return False
lb = 0.0
ub = 3000 * 100
while ub - lb > EPS:
	mid = (ub + lb) / 2
	if check(mid):
		ub = mid
	else:
		lb = mid
print(ub)


import cmath, sys
input = sys.stdin.readline
EPS = 1e-09

def cdist(z1, z2=0):
	return abs(z1 - z2)

def cInDiv(z1, z2, p, q):
	return (q * z1 + p * z2) / (p + q)

def cOutDiv(z1, z2, p, q):
	return (-q * z1 + p * z2) / (p - q)

def cInCircle(z, c, r):
	d = abs(z - c)
	if abs(r - d) < EPS:
		return 0
	if r - d > 0:
		return -1
	return 1

def cIntersectionPnt(z1, z2, r1, r2):
	d = abs(z1 - z2)
	if d < EPS:
		if abs(r1 - r2) < EPS:
			return (float('inf'), -1, -1)
		else:
			return (0, -1, -1)
	if abs(d - (r1 + r2)) < EPS:
		diff = (z2 - z1) / d
		return (1, z1 + diff * r1, -1)
	if abs(d - (r1 - r2)) < EPS:
		diff = (z2 - z1) / d
		return (1, z1 + diff * r1, -1)
	if abs(d - (r2 - r1)) < EPS:
		diff = (z1 - z2) / d
		return (1, z2 + diff * r2, -1)
	if d > r1 + r2:
		return (0, -1, -1)
	if d < abs(r1 - r2):
		return (0, -1, -1)
	rc = (r1 * r1 + d * d - r2 * r2) / (2 * d)
	rs = cmath.sqrt(r1 * r1 - rc * rc)
	diff = (z2 - z1) / d
	return (2, z1 + diff * rc + diff * 1j * rs, z1 + diff * rc + diff * -1j * rs)
(n, k) = map(int, input().split())
xy = []
c = []
for i in range(n):
	(xx, yy, cc) = map(int, input().split())
	xy.append(xx + yy * 1j)
	c.append(cc)

def judge(t):
	points = []
	for i in range(n):
		for j in range(i + 1, n):
			(flag, pt1, pt2) = cIntersectionPnt(xy[i], xy[j], t / c[i], t / c[j])
			if flag == 1:
				points.append(pt1)
			elif flag == 2:
				points.append(pt1)
				points.append(pt2)
	for pc in xy:
		points.append(pc)
	for z in points:
		cnt = 0
		for i in range(n):
			flag = cInCircle(z, xy[i], t / c[i])
			if flag <= 0:
				cnt += 1
		if cnt >= k:
			return True
	return False
ok = 10 ** 10
ng = 0
while abs(ok - ng) > EPS:
	mid = (ok + ng) / 2
	if judge(mid):
		ok = mid
	else:
		ng = mid
print(ok)


(N, K) = map(int, input().split())
XYC = [list(map(int, input().split())) for _ in [0] * N]
eps = 1e-07

def f(x, y, t):
	ret = 0
	for (X, Y, C) in XYC:
		if (x - X) ** 2 + (y - Y) ** 2 <= (t / C) ** 2 + eps:
			ret += 1
	return ret

def get_cross_section(x1, y1, r1, x2, y2, r2):
	d = ((x1 - x2) ** 2 + (y1 - y2) ** 2) ** 0.5
	X = (d * d + r1 * r1 - r2 * r2) / (2 * d)
	Y = max(0, r1 * r1 - X * X) ** 0.5
	dx = (x2 - x1) / d
	dy = (y2 - y1) / d
	ret = [(x1 + X * dx + Y * dy, y1 + X * dy - Y * dx)]
	if Y > 0:
		ret.append((x1 + X * dx - Y * dy, y1 + X * dy + Y * dx))
	return ret

def check(t):
	kouho = []
	for i in range(N):
		(x1, y1, c1) = XYC[i]
		kouho.append((x1, y1))
		for j in range(i + 1, N):
			(x2, y2, c2) = XYC[j]
			tmp = get_cross_section(x1, y1, t / c1, x2, y2, t / c2)
			for tmp2 in tmp:
				kouho.append(tmp2)
	for tmp in kouho:
		if f(tmp[0], tmp[1], t) >= K:
			return True
	return False
l = 0
r = 1000000
for _ in range(100):
	i = (l + r) / 2
	if check(i):
		r = i
	else:
		l = i
print(r)


import cmath
import itertools
import math
import os
import random
import sys
INF = float('inf')
PI = cmath.pi
TAU = cmath.pi * 2
EPS = 1e-10
if os.getenv('LOCAL'):
	sys.stdin = open('_in.txt', 'r')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
IINF = 10 ** 18
MOD = 10 ** 9 + 7

class Point:
	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):
		c = self.c + p.c
		return Point(c.real, c.imag)

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

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

	def __isub__(self, 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)

	@staticmethod
	def ccw(a, b, 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):
		return self.x * p.x + self.y * p.y

	def det(self, p):
		return self.x * p.y - self.y * p.x

	def dist(self, p):
		return abs(self.c - p.c)

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

	def phase(self):
		return cmath.phase(self.c)

	def angle(self, p, q):
		return (cmath.phase(q.c - self.c) - cmath.phase(p.c - self.c) + PI) % TAU - PI

	def area(self, p, q):
		return abs((p - self).det(q - self) / 2)

	def projection_point(self, p, q, allow_outer=False):
		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):
		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):
		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):
		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):
		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):
		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):
		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):
		return abs(self.o.dist(p) - self.r) < EPS

	def contains(self, p, allow_on_edge=True):
		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):
		sector_area = self.area() * angle / TAU
		return sector_area - self.r ** 2 * math.sin(angle) / 2

	def intersection_points(self, other, allow_outer=False):
		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):
		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):
		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):
		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):
		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):
		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 = 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

def argsort(li, key=None, reverse=False):
	return [i for (_, i) in sorted([(a, i) for (i, a) in enumerate(li)], key=(lambda t: key(t[0])) if key else None, reverse=reverse)]
(N, K) = list(map(int, sys.stdin.buffer.readline().split()))
XYC = [list(map(int, sys.stdin.buffer.readline().split())) for _ in range(N)]

def test(t: float):
	circles = []
	for (x, y, c) in XYC:
		circles.append(Circle(Point(x, y), t / c))
	points = []
	for (c1, c2) in itertools.combinations(circles, r=2):
		points += c1.intersection_points_with_circle(c2)
	for c in circles:
		points.append(c.o)
	for p in points:
		cnt = 0
		for c in circles:
			cnt += c.contains(p)
		if cnt >= K:
			return True
	return False
ok = 1 << 100
ng = 0
while abs(ok - ng) > EPS:
	mid = (ok + ng) / 2
	if test(mid):
		ok = mid
	else:
		ng = mid
print(ok)


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)


from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect

def LI():
	return [int(x) for x in sys.stdin.readline().split()]

def I():
	return int(sys.stdin.readline())

def LS():
	return [list(x) for x in sys.stdin.readline().split()]

def S():
	res = list(sys.stdin.readline())
	if res[-1] == '\n':
		return res[:-1]
	return res

def IR(n):
	return [I() for i in range(n)]

def LIR(n):
	return [LI() for i in range(n)]

def SR(n):
	return [S() for i in range(n)]

def LSR(n):
	return [LS() for i in range(n)]
sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():

	def D2(x1, y1, x2, y2):
		return (x1 - x2) ** 2 + (y1 - y2) ** 2

	def check(R1, R2):
		(x1, y1, r1) = R1
		(x2, y2, r2) = R2
		d2 = D2(x1, y1, x2, y2)
		if (r1 - r2) ** 2 < d2 <= (r1 + r2) ** 2:
			return 1
		else:
			return 0

	def point(R1, R2):
		if not check(R1, R2):
			return []
		else:
			(x1, y1, r1) = R1
			(x2, y2, r2) = R2
			x2 -= x1
			y2 -= y1
			r = x2 ** 2 + y2 ** 2
			a = (r + r1 ** 2 - r2 ** 2) / 2
			d = (r * r1 ** 2 - a ** 2) ** 0.5
			(X, Y) = (a * x2 / r, a * y2 / r)
			k = d / r
			(X1, Y1) = (X + y2 * k + x1, Y - x2 * k + y1)
			(X2, Y2) = (X - y2 * k + x1, Y + x2 * k + y1)
			return [(X1, Y1), (X2, Y2)]

	def inR(p, R):
		(x2, y2) = p
		(x1, y1, r1) = R
		d2 = D2(x1, y1, x2, y2)
		if d2 <= r1 ** 2 + 0.001:
			return 1
		else:
			return 0
	(n, k) = LI()
	p = LIR(n)
	l = 0
	r = 1000000
	while r - l > 1e-06:
		t = (l + r) / 2
		P = []
		for i in range(n):
			(xi, yi, ci) = p[i]
			ri = t / ci
			P.append((xi, yi))
			for j in range(i):
				(xj, yj, cj) = p[j]
				rj = t / cj
				ps = point((xi, yi, ri), (xj, yj, rj))
				for pi in ps:
					P.append(pi)
		for pi in P:
			s = 0
			for (x, y, c) in p:
				r1 = t / c
				if inR(pi, (x, y, r1)):
					s += 1
				if s >= k:
					break
			if s >= k:
				r = t
				break
		else:
			l = t
	print(l)
	return
solve()


import sys
readline = sys.stdin.buffer.readline
EPS = 1e-07

class Circle:

	def __init__(self, cx, cy, r):
		self.center = (cx, cy)
		self.radius = r

	def cross(self, C2):
		(x1, y1) = self.center
		(x2, y2) = C2.center
		R1 = self.radius
		R2 = C2.radius
		if (R2 - R1) ** 2 + EPS <= (x2 - x1) ** 2 + (y2 - y1) ** 2 <= (R2 + R1) ** 2 - EPS:
			(dx, dy) = (x2 - x1, y2 - y1)
			a = (R2 ** 2 - R1 ** 2 + x1 ** 2 - x2 ** 2 + y1 ** 2 - y2 ** 2) / 2
			if abs(dy) > EPS:
				D = dx ** 2 + dy ** 2
				bx = a * dx + dx * dy * y1 - x1 * dy ** 2
				cx = dy ** 2 * (x1 ** 2 - R1 ** 2) + (a + dy * y1) ** 2
				cx1 = (-bx + (bx ** 2 - D * cx) ** 0.5) / D
				cx2 = (-bx - (bx ** 2 - D * cx) ** 0.5) / D
				cy1 = -(dx * cx1 + a) / dy
				cy2 = -(dx * cx2 + a) / dy
			else:
				k = (R1 ** 2 - R2 ** 2 + dx ** 2) / 2 / dx
				cx1 = cx2 = x1 + k
				cy1 = y1 + (R1 ** 2 - k ** 2) ** 0.5
				cy2 = y1 - (R1 ** 2 - k ** 2) ** 0.5
			return [(cx1, cy1), (cx2, cy2)]
		else:
			return []

	def isinside(self, x, y):
		(x1, y1) = self.center
		return (x1 - x) ** 2 + (y1 - y) ** 2 - EPS < self.radius ** 2
(N, K) = map(int, readline().split())
Points = [tuple(map(int, readline().split())) for _ in range(N)]
ok = 1000000.0
ng = 0
candidate = [(x, y) for (x, y, _) in Points]
for _ in range(40):
	med = (ok + ng) / 2
	Cs = [Circle(x, y, med / c) for (x, y, c) in Points]
	candidate2 = candidate[:]
	for i in range(N):
		for j in range(i):
			candidate2.extend(Cs[i].cross(Cs[j]))
	for (px, py) in candidate2:
		res = 0
		for C in Cs:
			if C.isinside(px, py):
				res += 1
		if res >= K:
			ok = med
			break
	else:
		ng = med
print(ok)


import sys
from itertools import combinations
from math import sqrt
import numpy as np
read = sys.stdin.read
readline = sys.stdin.readline

def main():
	(N, K, *xyc) = list(map(int, read().split()))
	x = xyc[::3]
	y = xyc[1::3]
	xy = list(zip(x, y))
	c = xyc[2::3]
	left = 0
	right = 10 ** 6
	delta = 0.1 ** 7
	while right - left > delta:
		mid = (left + right) / 2
		intersections = []
		r = [(mid / i) ** 2 for i in c]
		for (i, j) in combinations(list(range(N)), 2):
			(x1, y1) = xy[i]
			(x2, y2) = xy[j]
			X = x2 - x1
			Y = y2 - y1
			XY = X ** 2 + Y ** 2
			r1 = r[i]
			r2 = r[j]
			a = (XY + r1 - r2) / 2
			b = XY * r1 - a ** 2
			if b < delta:
				continue
			b = sqrt(b)
			xi1 = (a * X + Y * b) / XY + x1
			yi1 = (a * Y - X * b) / XY + y1
			xi2 = (a * X - Y * b) / XY + x1
			yi2 = (a * Y + X * b) / XY + y1
			intersections.append((xi1, yi1))
			intersections.append((xi2, yi2))
		intersections.extend(xy)
		intersections = np.array(intersections, np.float)
		cnt = np.zeros(len(intersections), np.int64)
		for ((i, j), k) in zip(xy, r):
			XY = (intersections[:, 0] - i) ** 2 + (intersections[:, 1] - j) ** 2
			cnt[XY < k + delta] += 1
		if np.any(cnt >= K):
			right = mid
		else:
			left = mid
	print(right)

def __starting_point():
	main()
__starting_point()


(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 = 1e-09

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 < 1e-06:
		break
print(ok)


from math import acos
from cmath import exp
from itertools import combinations
(N, K) = list(map(int, input().split()))
XYC = []
for _ in range(N):
	(x, y, c) = list(map(int, input().split()))
	XYC.append((complex(x, y), c))
if K == 1:
	print(0)
	return
ans = 1e+300
eps = 1e-07
for ((p1, c1), (p2, c2)) in combinations(XYC, 2):
	p_center = (p1 * c1 + p2 * c2) / (c1 + c2)
	t = abs(p_center - p1) * c1
	k = 0
	for (xy, c) in XYC:
		if abs(p_center - xy) * c < t + eps:
			k += 1
	if k >= K and t < ans:
		ans = t

def get_center(p1, p2, p3, c1, c2, c3):
	if c1 == c2 == c3:
		(t1, t2, t3) = (p2 - p3, p3 - p1, p1 - p2)
		denom = t1 * p1.conjugate() + t2 * p2.conjugate() + t3 * p3.conjugate()
		if denom == 0:
			return []
		return [(t1 * abs(p1) ** 2 + t2 * abs(p2) ** 2 + t3 * abs(p3) ** 2) / denom]
	elif c1 == c3:
		(c2, c3) = (c3, c2)
		(p2, p3) = (p3, p2)
	elif c2 == c3:
		(c1, c3) = (c3, c1)
		(p1, p3) = (p3, p1)
	o1 = (c1 * c1 * p1 - c3 * c3 * p3) / (c1 * c1 - c3 * c3)
	r1 = c1 * c3 * abs(p1 - p3) / abs(c1 * c1 - c3 * c3)
	o2 = (c2 * c2 * p2 - c3 * c3 * p3) / (c2 * c2 - c3 * c3)
	r2 = c2 * c3 * abs(p2 - p3) / abs(c2 * c2 - c3 * c3)
	l = abs(o1 - o2)
	if r1 + r2 < l or l + r1 < r2 or l + r2 < r1:
		return []
	cos_a = (r1 * r1 + l * l - r2 * r2) / (2 * r1 * l)
	a = acos(cos_a)
	res1 = o1 + (o2 - o1) * exp(a * 1j) * r1 / l
	res2 = o1 + (o2 - o1) * exp(-a * 1j) * r1 / l
	return [res1, res2]
for ((p1, c1), (p2, c2), (p3, c3)) in combinations(XYC, 3):
	p_centers = get_center(p1, p2, p3, c1, c2, c3)
	for p_center in p_centers:
		t = abs(p1 - p_center) * c1
		k = 0
		for (p, c) in XYC:
			if abs(p_center - p) * c < t + eps:
				k += 1
		if k >= K and t < ans:
			ans = t
print(ans)


EPS = 10 ** (-7)
(N, K) = map(int, input().split())
xyc = [list(map(int, input().split())) for _ in range(N)]

def possible(t):
	res = False
	cand = []
	for i in range(N):
		cand.append(xyc[i][:2])
		(x1, y1, c1) = xyc[i]
		r1 = t / c1
		for j in range(i + 1, N):
			(x2, y2, c2) = xyc[j]
			r2 = t / c2
			d = ((x2 - x1) ** 2 + (y2 - y1) ** 2) ** 0.5
			if abs(r1 - r2) + EPS < d < r1 + r2 - EPS:
				mx = x1 + (x2 - x1) * (r1 ** 2 - r2 ** 2 + d ** 2) / (2 * d ** 2)
				my = y1 + (y2 - y1) * (r1 ** 2 - r2 ** 2 + d ** 2) / (2 * d ** 2)
				l = abs((r1 ** 2 - (mx - x1) ** 2 - (my - y1) ** 2) ** 0.5)
				nx = (y2 - y1) / d
				ny = -(x2 - x1) / d
				cand.append([mx + nx * l, my + ny * l])
				cand.append([mx - nx * l, my - ny * l])
	for (X, Y) in cand:
		n = 0
		for i in range(N):
			(x, y, c) = xyc[i]
			if c * ((X - x) ** 2 + (Y - y) ** 2) ** 0.5 < t + EPS:
				n += 1
		if n >= K:
			res = True
	return res
ng = 0
ok = 10 ** 6
m = (ng + ok) / 2
for i in range(100):
	if possible(m):
		ok = m
	else:
		ng = m
	m = (ok + ng) / 2
print(m)


import numpy as np
from scipy.optimize import fmin
(n, k) = list(map(int, input().split()))
XYC = [list(map(int, input().split())) for i in range(n)]
(X, Y, C) = ([], [], [])
for (x, y, c) in XYC:
	X.append(x)
	Y.append(y)
	C.append(c)
X = np.array(X, dtype=np.float)
Y = np.array(Y, dtype=np.float)
C = np.array(C, dtype=np.float)

def f(xy):
	(x, y) = xy
	times = (X - x) * (X - x) + (Y - y) * (Y - y)
	times = C * np.sqrt(times)
	times = np.sort(times)
	return times[k - 1]
deff = 0.5
ansx = [fmin(f, (x, y), disp=False, ftol=10 ** (-7), initial_simplex=[(x + deff, y), (x - deff, y + deff), (x - deff, y - deff)]) for (x, y, c) in XYC]
ansy = list([f(x) for x in ansx])
print(min(ansy))


import cmath
import itertools
import math
import os
import random
import sys
INF = float('inf')
PI = cmath.pi
TAU = cmath.pi * 2
EPS = 1e-08

class Point:
	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):
		c = self.c + p.c
		return Point(c.real, c.imag)

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

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

	def __isub__(self, 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):
		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):
		return self.x * p.x + self.y * p.y

	def det(self, p):
		return self.x * p.y - self.y * p.x

	def dist(self, p):
		return abs(self.c - p.c)

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

	def phase(self):
		return cmath.phase(self.c)

	def angle(self, p, q):
		return (cmath.phase(q.c - self.c) - cmath.phase(p.c - self.c) + PI) % TAU - PI

	def area(self, p, q):
		return -abs((p - self).det(q - self) / 2)

	def projection_point(self, p, q, allow_outer=False):
		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):
		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):
		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):
		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):
		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):
		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):
		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):
		return abs(self.o.dist(p) - self.r) < EPS

	def contains(self, p, allow_on_edge=True):
		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):
		sector_area = self.area() * angle / TAU
		return sector_area - self.r ** 2 * math.sin(angle) / 2

	def intersection_points(self, other, allow_outer=False):
		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):
		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):
		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):
		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):
		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):
		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 = 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:

	def __init__(self, a: float, b: float, c: float):
		self.a = a
		self.b = b
		self.c = c

	@staticmethod
	def from_gradient(grad: float, intercept: float):
		return Line(grad, -1, intercept)

	@staticmethod
	def from_segment(p1, 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):
		return abs(Point(self.a, self.b).det(Point(l.a, l.b))) < EPS

	def is_orthogonal_to(self, l):
		return abs(Point(self.a, self.b).dot(Point(l.a, l.b))) < EPS

	def intersection_point(self, l):
		(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):
		raise NotImplementedError()

	def has_point(self, p):
		return abs(self.a * p.x + self.b * p.y + self.c) < EPS

class Segment:

	def __init__(self, p1, p2):
		self.p1 = p1
		self.p2 = p2

	def norm(self):
		return abs(self.p1 - self.p2)

	def phase(self):
		return (self.p2 - self.p1).phase()

	def is_parallel_to(self, s):
		return abs((self.p1 - self.p2).det(s.p1 - s.p2)) < EPS

	def is_orthogonal_to(self, s):
		return abs((self.p1 - self.p2).dot(s.p1 - s.p2)) < EPS

	def intersects_with(self, s, allow_side=True):
		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):
		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):
		return abs(p - self.closest_point(p))

	def dist_segment(self, 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):
		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


import sys
input = sys.stdin.buffer.readline
(n, k) = map(int, input().split())
XY = []
C = []
kouho = []
for i in range(n):
	(x, y, c) = map(int, input().split())
	XY.append((x, y))
	C.append(c)
	kouho.append(complex(x, y))
ct = 100
eps = 10 ** (-7)

class circle:

	def __init__(self, center, r):
		self.center = center
		self.r = r

def circle_cross(c1, c2):
	r1 = c1.r
	o1 = c1.center
	r2 = c2.r
	o2 = c2.center
	d = abs(o1 - o2)
	if d > r1 + r2:
		return (0, 0, 0)
	elif r1 + r2 < d + eps and r1 + r2 > d - eps:
		return (1, (r2 * o1 + r1 * o2) / (r1 + r2), 0)
	elif d < r1 + r2 and d > abs(r1 - r2):
		o21 = o2 - o1
		oh_nagasa = (d ** 2 + r1 ** 2 - r2 ** 2) / (2 * d)
		if oh_nagasa < eps:
			return (1, (r2 * o1 + r1 * o2) / (r1 + r2), 0)
		oh = oh_nagasa * (o21 / d)
		housen = o21 / d * complex(0, 1)
		suisen = max(0, (r1 ** 2 - oh_nagasa ** 2) ** (1 / 2))
		ans1 = o1 + oh + housen * suisen
		ans2 = o1 + oh - housen * suisen
		return (2, ans1, ans2)
	elif abs(r1 - r2) > d - eps and abs(r1 - r2) < d + eps:
		ans = (-r2 * o1 + r1 * o2) / (r1 - r2)
		return (1, ans, 0)
	else:
		return (0, 0, 0)
if n == 1:
	print(0)
	exit()
if k == 1:
	print(0)
	exit()
ok = 10 ** 10
ng = 0
while ct > 0:
	mid = (ok + ng) / 2
	kouho_temp = kouho[:]
	for i in range(n - 1):
		(a, b) = XY[i]
		p = C[i]
		A = circle(complex(a, b), mid / p)
		for j in range(i + 1, n):
			(c, d) = XY[j]
			q = C[j]
			B = circle(complex(c, d), mid / q)
			(t1, t2, t3) = circle_cross(A, B)
			if t1 == 0:
				continue
			if t1 == 1:
				kouho_temp.append(t2)
			if t1 == 2:
				kouho_temp.append(t2)
				kouho_temp.append(t3)
	res = 0
	for z in kouho_temp:
		cnt = 0
		for i in range(n):
			(x, y) = XY[i]
			p = C[i]
			z1 = complex(x, y)
			if abs(z - z1) < mid / p + eps:
				cnt += 1
		res = max(cnt, res)
	if res >= k:
		ok = mid
	else:
		ng = mid
	ct -= 1
print(mid)


import math
import sys
from itertools import combinations
stdin = sys.stdin

def ni():
	return int(ns())

def na():
	return list(map(int, stdin.readline().split()))

def naa(N):
	return [na() for _ in range(N)]

def ns():
	return stdin.readline().rstrip()

def circumcircle(ax, ay, bx, by, cx, cy):
	if (bx - ax) * (cy - ay) - (by - ay) * (cx - ax) == 0:
		return None
	D = 2 * (ax * (by - cy) + bx * (cy - ay) + cx * (ay - by))
	X = ((ax * ax + ay * ay) * (by - cy) + (bx * bx + by * by) * (cy - ay) + (cx * cx + cy * cy) * (ay - by)) / D
	Y = ((ax * ax + ay * ay) * (cx - bx) + (bx * bx + by * by) * (ax - cx) + (cx * cx + cy * cy) * (bx - ax)) / D
	R = math.sqrt((X - ax) * (X - ax) + (Y - ay) * (Y - ay))
	return (X, Y, R)

def diametercircle(ax, ay, bx, by):
	X = (ax + bx) / 2
	Y = (ay + by) / 2
	R = math.sqrt((X - ax) * (X - ax) + (Y - ay) * (Y - ay))
	return (X, Y, R)

def distance(ax, ay, bx, by):
	return math.sqrt((ax - bx) ** 2 + (ay - by) ** 2)

def intersectioncircle(ax, ay, ra, bx, by, rb):
	d = distance(ax, ay, bx, by)
	if d > ra + rb:
		return None
	if d < abs(ra - rb):
		return None
	if d == 0:
		return None
	t = (ra ** 2 - rb ** 2 + d ** 2) / (2 * d)
	h = math.sqrt(ra ** 2 - t ** 2 + sys.float_info.epsilon)
	x2 = ax + t * (bx - ax) / d
	y2 = ay + t * (by - ay) / d
	x3 = x2 + h * (by - ay) / d
	y3 = y2 - h * (bx - ax) / d
	x4 = x2 - h * (by - ay) / d
	y4 = y2 + h * (bx - ax) / d
	return (x3, y3, x4, y4)

def eat_count(cx, cy, t):
	eat = 0
	for xyc in XYC_array:
		(dx, dy, c) = xyc
		if distance(cx, cy, dx, dy) <= t / c + 10 ** (-8):
			eat += 1
	return eat
(N, K) = na()
XYC_array = naa(N)
mint = 0
maxt = 10 ** 6
eps = 10 ** (-6)
while maxt - mint > eps:
	t = (mint + maxt) / 2
	ok_flag = 0
	for xyc in XYC_array:
		(cx, cy, _) = xyc
		if eat_count(cx, cy, t) >= K:
			ok_flag = 1
			break
	if ok_flag == 1:
		maxt = t
		continue
	for p in combinations(range(N), 2):
		(ax, ay, ca) = XYC_array[p[0]]
		(bx, by, cb) = XYC_array[p[1]]
		if intersectioncircle(ax, ay, t / ca, bx, by, t / cb):
			(X1, Y1, X2, Y2) = intersectioncircle(ax, ay, t / ca, bx, by, t / cb)
			if eat_count(X1, Y1, t) >= K or eat_count(X2, Y2, t) >= K:
				ok_flag = 1
				break
	if ok_flag == 1:
		maxt = t
	else:
		mint = t
print(t)


from math import sqrt

def crosscircle(c1, c2):
	(x1, y1, r1) = c1
	(x2, y2, r2) = c2
	if (x1 - x2) ** 2 + (y1 - y2) ** 2 > (r1 + r2) ** 2:
		return ()
	elif x1 == x2 and y1 == y2:
		return ()
	elif (x1 - x2) ** 2 + (y1 - y2) ** 2 == (r1 + r2) ** 2:
		x = (x1 * r2 + x2 * r1) / (r1 + r2)
		y = (y1 * r2 + y2 * r1) / (r1 + r2)
		return ((x, y),)
	elif y1 == y2:
		x = (r1 ** 2 - r2 ** 2 - x1 ** 2 + x2 ** 2) / (2 * (x2 - x1))
		if y1 ** 2 - (y1 ** 2 - r1 ** 2 + (x - x1) ** 2) >= 0:
			yans1 = y1 + sqrt(y1 ** 2 - (y1 ** 2 - r1 ** 2 + (x - x1) ** 2))
			yans2 = y1 - sqrt(y1 ** 2 - (y1 ** 2 - r1 ** 2 + (x - x1) ** 2))
			return ((x, yans1), (x, yans2))
		else:
			return ()
	elif x1 == x2:
		y = (r1 ** 2 - r2 ** 2 - y1 ** 2 + y2 ** 2) / (2 * (y2 - y1))
		if x1 ** 2 - (x1 ** 2 - r1 ** 2 + (y - y1) ** 2) >= 0:
			xans1 = x1 + sqrt(x1 ** 2 - (x1 ** 2 - r1 ** 2 + (y - y1) ** 2))
			xans2 = x1 - sqrt(x1 ** 2 - (x1 ** 2 - r1 ** 2 + (y - y1) ** 2))
			return ((xans1, y), (xans2, y))
		else:
			return ()
	else:
		A = ((x1 - x2) / (y1 - y2)) ** 2 + 1
		B = (x1 - x2) * (r1 ** 2 - r2 ** 2 - x1 ** 2 + x2 ** 2 + (y1 - y2) ** 2) / (y1 - y2) ** 2 - 2 * x1
		C = ((r1 ** 2 - r2 ** 2 - x1 ** 2 + x2 ** 2 + (y1 - y2) ** 2) / (2 * (y1 - y2))) ** 2 + x1 ** 2 - r1 ** 2
		if B ** 2 - 4 * A * C >= 0:
			xans1 = (-B + sqrt(B ** 2 - 4 * A * C)) / (2 * A)
			xans2 = (-B - sqrt(B ** 2 - 4 * A * C)) / (2 * A)
			yans1 = -(r1 ** 2 - r2 ** 2 - x1 ** 2 + x2 ** 2 - y1 ** 2 + y2 ** 2) / (2 * (y1 - y2)) - xans1 * (x1 - x2) / (y1 - y2)
			yans2 = -(r1 ** 2 - r2 ** 2 - x1 ** 2 + x2 ** 2 - y1 ** 2 + y2 ** 2) / (2 * (y1 - y2)) - xans2 * (x1 - x2) / (y1 - y2)
			return ((xans1, yans1), (xans2, yans2))
		else:
			return ()
(N, K) = map(int, input().split())
li = [tuple(map(int, input().split())) for i in range(N)]
eps = 1e-06
U = 200000.0
L = 0
while U - L > 1e-06:
	T = (U + L) / 2
	points = []
	for i in range(N - 1):
		for j in range(i + 1, N):
			c1 = (li[i][0], li[i][1], T / li[i][2])
			c2 = (li[j][0], li[j][1], T / li[j][2])
			p = crosscircle(c1, c2)
			if p == ():
				continue
			for a in p:
				points.append(a)
	for i in range(N):
		points.append((li[i][0], li[i][1]))
	Max = 0
	for p in points:
		cnt = 0
		for i in range(N):
			(x, y, r) = (li[i][0], li[i][1], T / li[i][2])
			if (p[0] - x) ** 2 + (p[1] - y) ** 2 <= (r + eps) ** 2:
				cnt += 1
		Max = max(Max, cnt)
	if Max < K:
		L = T
	else:
		U = T
print(T)


from math import hypot
(N, K) = map(int, input().split())

def count(x, y, T, cs):
	r = 0
	for (a, b, c) in cs:
		r += int(hypot(x - a, y - b) <= T / c + 10 ** (-8))
	return r

def ko(x1, y1, r1, r2):
	a = (x1 ** 2 + y1 ** 2 + r1 ** 2 - r2 ** 2) / 2
	t = (x1 ** 2 + y1 ** 2) * r1 ** 2 - a ** 2
	if t < 0:
		return -1
	x = a * x1
	xb = y1 * t ** (1 / 2)
	y = a * y1
	yb = x1 * t ** (1 / 2)
	b = x1 ** 2 + y1 ** 2
	return (((x + xb) / b, (y - yb) / b), ((x - xb) / b, (y + yb) / b))

def zko(x1, y1, r1, x2, y2, r2):
	r = ko(x2 - x1, y2 - y1, r1, r2)
	if r == -1:
		return -1
	((xp, yp), (xm, ym)) = ko(x2 - x1, y2 - y1, r1, r2)
	return ((xp + x1, yp + y1), (xm + x1, ym + y1))

def f(T, cs):
	ccs = []
	for i in range(N):
		(xi, yi, ci) = cs[i]
		for j in range(i + 1, N):
			(xj, yj, cj) = cs[j]
			r = zko(xi, yi, T / ci, xj, yj, T / cj)
			if r == -1:
				continue
			((x1, y1), (x2, y2)) = r
			ccs.append((x1, y1))
			ccs.append((x2, y2))
	for (a, b, c) in cs:
		ccs.append((a, b))
	for (x, y) in ccs:
		if count(x, y, T, cs) >= K:
			return True
	return False
cs = []
for i in range(N):
	(x, y, c) = map(int, input().split())
	cs.append((x, y, c))
(mx, mn) = (10 ** 9, -1)
idx = mx / 2
for _ in range(100):
	if f(idx, cs):
		(idx, mx) = ((idx + mn) / 2, idx)
		continue
	(idx, mn) = ((idx + mx) / 2, idx)
print(idx)