Language: C++

include <stdio.h>
#include <math.h>
struct point {
	double x;
	double y;
};
point naibun(point p1, point p2, double t1, double t2) {
	double t = t1 + t2;
	t1 /= t;
	t2 /= t;
	point p;
	p.x = p1.x * t2 + p2.x * t1;
	p.y = p1.y * t2 + p2.y * t1;
	return p;
}
struct line {
	//ax+by+c=0
	//a*a+b*b=1
	double a;
	double b;
	double c;
};
struct circle {
	point center;
	double r;
};
double distance(point p1, point p2) {
	return sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
}
line makeline(point p1, point p2) {
	line l;
	l.a = p1.y - p2.y;
	l.b = p2.x - p1.x;
	l.c = p1.x * p2.y - p2.x * p1.y;
	double t;
	t = sqrt(l.a * l.a + l.b * l.b);
	l.a /= t;
	l.b /= t;
	l.c /= t;
	return l;
}
circle makecircle(point p, double r) {
	circle c;
	c.center = p;
	c.r = r;
	return c;
}
point llintersect(line l1, line l2) {
	point p;
	p.x = (l1.b * l2.c - l2.b * l1.c) / (l1.a * l2.b - l2.a * l1.b);
	p.y = (l1.a * l2.c - l2.a * l1.c) / (l2.a * l1.b - l1.a * l2.b);
	return p;
}
line perpendicular(point p, line l1) {
	line l;
	l.a = l1.b;
	l.b = -l1.a;
	l.c = l1.a * p.y - l1.b * p.x;
	double t;
	t = sqrt(l.a * l.a + l.b * l.b);
	l.a /= t;
	l.b /= t;
	l.c /= t;
	return l;
}
point lcintersectA(line l, circle c) {
	point p;
	line l1;
	double d;
	l1 = perpendicular(c.center, l);
	p = llintersect(l, l1);
	d = distance(c.center, p);
	d = sqrt(c.r * c.r - d * d);
	p.x += l1.a * d;
	p.y += l1.b * d;
	return p;
}
point lcintersectB(line l, circle c) {
	point p;
	line l1;
	double d;
	l1 = perpendicular(c.center, l);
	p = llintersect(l, l1);
	d = distance(c.center, p);
	d = sqrt(c.r * c.r - d * d);
	p.x -= l1.a * d;
	p.y -= l1.b * d;
	return p;
}
line ccroot(circle c1, circle c2) {
	line l;
	l.a = -2 * c1.center.x + 2 * c2.center.x;
	l.b = -2 * c1.center.y + 2 * c2.center.y;
	l.c = c1.center.x * c1.center.x + c1.center.y * c1.center.y - c1.r * c1.r;
	l.c -= c2.center.x * c2.center.x + c2.center.y * c2.center.y - c2.r * c2.r;
	double t;
	t = sqrt(l.a * l.a + l.b * l.b);
	l.a /= t;
	l.b /= t;
	l.c /= t;
	return l;
}
point ccintersectA(circle c1, circle c2) {
	line l;
	l = ccroot(c1, c2);
	return lcintersectA(l, c1);
}
point ccintersectB(circle c1, circle c2) {
	line l;
	l = ccroot(c1, c2);
	return lcintersectB(l, c1);
}
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	if (k == 1) {
		printf("0\n");
		return 0;
	}
	point p[60];
	point q, r, m;
	line l[60][60];
	circle o[60][60];
	double t;
	int e;
	double ans;
	double c[60];
	ans = 2000 * 100;
	for (int i = 0; i < n; i++) {
		scanf("%lf%lf", &p[i].x, &p[i].y);
		scanf("%lf", c + i);
		c[i] = 1 / c[i];
	}
	for (int i1 = 0; i1 < n; i1++) {
		for (int i2 = i1 + 1; i2 < n; i2++) {
			q = naibun(p[i1], p[i2], c[i1], c[i2]);
			t = (1 / c[i1]) * distance(p[i1], q);
			if (t < ans) {
				e = 0;
				for (int i4 = 0; i4 < n; i4++) {
					if ((1 / c[i4]) * distance(p[i4], q) - 0.0000001 <= t)e++;
				}
				if (e >= k)ans = t;
			}
			if (c[i1] != c[i2]) {
				q = naibun(p[i1], p[i2], -c[i1], c[i2]);
				t = (1 / c[i1]) * distance(p[i1], q);
				if (t < ans) {
					e = 0;
					for (int i4 = 0; i4 < n; i4++) {
						if ((1 / c[i4]) * distance(p[i4], q) - 0.0000001 <= t)e++;
					}
					if (e >= k)ans = t;
				}
			}
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			if (c[i] == c[j]) {
				q = naibun(p[i], p[j], 1, 1);
				l[i][j] = perpendicular(q, makeline(p[i], p[j]));
			}
			else {
				q = naibun(p[i], p[j], c[i], c[j]);
				r = naibun(p[i], p[j], -c[i], c[j]);
				m = naibun(q, r, 1, 1);
				o[i][j] = makecircle(m, distance(m, q));
			}
		}
	}
	for (int i1 = 0; i1 < n; i1++) {
		for (int i2 = i1 + 1; i2 < n; i2++) {
			for (int i3 = i2 + 1; i3 < n; i3++) {
				if (c[i1] == c[i2] && c[i1] == c[i3]) {
					if (l[i1][i2].a * l[i1][i3].b != l[i1][i2].b * l[i1][i3].a) {
						q = llintersect(l[i1][i2], l[i1][i3]);
						t = (1 / c[i1]) * distance(p[i1], q);
						if (t < ans) {
							e = 0;
							for (int i4 = 0; i4 < n; i4++) {
								if ((1 / c[i4]) * distance(p[i4], q) - 0.0000001 <= t)e++;
							}
							if (e >= k)ans = t;
						}
					}
				}
				if (c[i1] == c[i2] && c[i1] != c[i3]) {
					if (fabs(o[i1][i3].center.x * l[i1][i2].a + o[i1][i3].center.y * l[i1][i2].b + l[i1][i2].c) < o[i1][i3].r) {
						q = lcintersectA(l[i1][i2], o[i1][i3]);
						t = (1 / c[i1]) * distance(p[i1], q);
						if (t < ans) {
							e = 0;
							for (int i4 = 0; i4 < n; i4++) {
								if ((1 / c[i4]) * distance(p[i4], q) - 0.0000001 <= t)e++;
							}
							if (e >= k)ans = t;
						}
						q = lcintersectB(l[i1][i2], o[i1][i3]);
						t = (1 / c[i1]) * distance(p[i1], q);
						if (t < ans) {
							e = 0;
							for (int i4 = 0; i4 < n; i4++) {
								if ((1 / c[i4]) * distance(p[i4], q) - 0.0000001 <= t)e++;
							}
							if (e >= k)ans = t;
						}
					}
				}
				if (c[i1] != c[i2] && c[i1] == c[i3]) {
					if (fabs(o[i1][i2].center.x * l[i1][i3].a + o[i1][i2].center.y * l[i1][i3].b + l[i1][i3].c) < o[i1][i2].r) {
						q = lcintersectA(l[i1][i3], o[i1][i2]);
						t = (1 / c[i1]) * distance(p[i1], q);
						if (t < ans) {
							e = 0;
							for (int i4 = 0; i4 < n; i4++) {
								if ((1 / c[i4]) * distance(p[i4], q) - 0.0000001 <= t)e++;
							}
							if (e >= k)ans = t;
						}
						q = lcintersectB(l[i1][i3], o[i1][i2]);
						t = (1 / c[i1]) * distance(p[i1], q);
						if (t < ans) {
							e = 0;
							for (int i4 = 0; i4 < n; i4++) {
								if ((1 / c[i4]) * distance(p[i4], q) - 0.0000001 <= t)e++;
							}
							if (e >= k)ans = t;
						}
					}
				}
				if (c[i1] != c[i2] && c[i1] != c[i3]) {
					t = distance(o[i1][i2].center, o[i1][i3].center);
					if (t < o[i1][i2].r + o[i1][i3].r && fabs(o[i1][i2].r - o[i1][i3].r) < t) {
						q = ccintersectA(o[i1][i3], o[i1][i2]);
						t = (1 / c[i1]) * distance(p[i1], q);
						if (t < ans) {
							e = 0;
							for (int i4 = 0; i4 < n; i4++) {
								if ((1 / c[i4]) * distance(p[i4], q) - 0.0000001 <= t)e++;
							}
							if (e >= k)ans = t;
						}
						q = ccintersectB(o[i1][i3], o[i1][i2]);
						t = (1 / c[i1]) * distance(p[i1], q);
						if (t < ans) {
							e = 0;
							for (int i4 = 0; i4 < n; i4++) {
								if ((1 / c[i4]) * distance(p[i4], q) - 0.0000001 <= t)e++;
							}
							if (e >= k)ans = t;
						}
					}
				}
			}
		}
	}
	printf("%.10lf\n", ans);
}

Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <stdio.h>
      | ^~~~~~~
In file included from /usr/include/c++/14/cmath:45,
                 from /usr/include/c++/14/math.h:36,
                 from a.cc:2:
/usr/include/c++/14/ext/type_traits.h:164:35: error: 'constexpr const bool __gnu_cxx::__is_null_pointer' redeclared as different kind of entity
  164 |   __is_null_pointer(std::nullptr_t)
      |                                   ^
/usr/include/c++/14/ext/type_traits.h:159:5: note: previous declaration 'template<class _Type> constexpr bool __gnu_cxx::__is_null_pointer(_Type)'
  159 |     __is_null_pointer(_Type)
      |     ^~~~~~~~~~~~~~~~~
/usr/include/c++/14/ext/type_traits.h:164:26: error: 'nullptr_t' is not a member of 'std'
  164 |   __is_null_pointer(std::nullptr_t)
      |                          ^~~~~~~~~
In file included from /usr/include/c++/14/bits/stl_pair.h:60,
                 from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906:
/usr/include/c++/14/type_traits:666:33: error: 'nullptr_t' is not a member of 'std'
  666 |     struct is_null_pointer<std::nullptr_t>
      |                                 ^~~~~~~~~
/usr/include/c++/14/type_traits:666:42: error: template argument 1 is invalid
  666 |     struct is_null_pointer<std::nullptr_t>
      |                                          ^
/usr/include/c++/14/type_traits:670:48: error: template argument 1 is invalid
  670 |     struct is_null_pointer<const std::nullptr_t>
      |                                                ^
/usr/include/c++/14/type_traits:674:51: error: template argument 1 is invalid
  674 |     struct is_null_pointer<volatile std::nullptr_t>
      |                                                   ^
/usr/include/c++/14/type_traits:678:57: error: template argument 1 is invalid
  678 |     struct is_null_pointer<const volatile std::nullptr_t>
      |                                                         ^
/usr/include/c++/14/type_traits:1429:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1429 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                     ^~~~~~
In file included from /usr/include/stdlib.h:32,
                 from /usr/include/c++/14/bits/std_abs.h:38,
                 from /usr/include/c++/14/cmath:49:
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1429:57: error: template argument 1 is invalid
 1429 |     : public integral_constant<std::size_t, alignof(_Tp)>
      |                                                         ^
/usr/include/c++/14/type_traits:1429:57: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1438:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1438 |     : public integral_constant<std::size_t, 0> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1438:46: error: template argument 1 is invalid
 1438 |     : public integral_constant<std::size_t, 0> { };
      |                                              ^
/usr/include/c++/14/type_traits:1438:46: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1440:26: error: 'std::size_t' has not been declared
 1440 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:1441:21: error: '_Size' was not declared in this scope
 1441 |     struct rank<_Tp[_Size]>
      |                     ^~~~~
/usr/include/c++/14/type_traits:1441:27: error: template argument 1 is invalid
 1441 |     struct rank<_Tp[_Size]>
      |                           ^
/usr/include/c++/14/type_traits:1442:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1442 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1442:65: error: template argument 1 is invalid
 1442 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                                                 ^
/usr/include/c++/14/type_traits:1442:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:1446:37: error: 'size_t' is not a member of 'std'; did you mean 'size_t'?
 1446 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                     ^~~~~~
/usr/lib/gcc/x86_64-linux-gnu/14/include/stddef.h:214:23: note: 'size_t' declared here
  214 | typedef __SIZE_TYPE__ size_t;
      |                       ^~~~~~
/usr/include/c++/14/type_traits:1446:65: error: template argument 1 is invalid
 1446 |     : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { };
      |                                                                 ^
/usr/include/c++/14/type_traits:1446:65: note: invalid template non-type parameter
/usr/include/c++/14/type_traits:2086:26: error: 'std::size_t' has not been declared
 2086 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:2087:30: error: '_Size' was not declared in this scope
 2087 |     struct remove_extent<_Tp[_Size]>
      |                              ^~~~~
/usr/include/c++/14/type_traits:2087:36: error: template argument 1 is invalid
 2087 |     struct remove_extent<_Tp[_Size]>
      |                                    ^
/usr/include/c++/14/type_traits:2099:26: error: 'std::size_t' has not been declared
 2099 |   template<typename _Tp, std::size_t _Size>
      |                          ^~~
/usr/include/c++/14/type_traits:2100:35: error: '_Size' was not declared in this scope
 2100 |     struct remove_all_extents<_Tp[_Size]>
      |                                   ^~~~~
/usr/include/c++/14/type_traits:2100:41: error: template argument 1 is invalid
 2100 |     struct remove_all_extents<_Tp[_Size]>
      |                                         ^
/usr/include/c++/14/type_traits:2171:12: error: 'std::size_t' has not been declared
 2171 |   template<std::size_t _Len>
      |            ^~~
/usr/include/c++/14/type_traits:2176:30: error: '_Len' was not declared in this scope
 2176 |         unsigned char __data[_Len];
      |                              ^~~~
/usr/include/c++/14/type_traits:2194:12: error: 'std::size_t' has not been declared
 2194 |   template<std::size_t _Len, std::size_t _Align =
      |            ^~~
/usr/include/c++/14/type_traits:2194:30: error: 'std::size_t' has not been declared
 2194 |   template<std::size_t _Len, std::size_t _Align =
      |                              ^~~
/usr/include/c++/14/type_traits:2195:55: error: '_Len' was not declared in this scope
 2195 |            __alignof__(typename __aligned_storage_msa<_Len>::__type)>
      |                                                       ^~~~
/usr/include/c++/14/type_traits:2195:59: error: template argument 1 is invalid
 2195 |            __alignof__(typename __aligned_storage_msa<_Len>::__type)>
      |                                                           ^
/usr/include/c++/14/type_traits:2202:30: error: '_Len' was not declared in this scope
 2202 |         unsigned char __data[_Len];
      |                              ^~~~
/usr/include/c++/14/type_traits:2203:44: error: '_Align' was not declared in this scope
 2203 |         struct __attribute__((__aligned__((_Align)))) { } __align;
      |                                            ^~~~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:65:
/usr/include/c++/14/bits/stl_iterator_base_types.h:125:67: error: 'ptrdiff_t' does not name a type
  125 |   template<typename _Category, typename _Tp, typename _Distance = ptrdiff_t,
      |                                                                   ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:1:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
  +++ |+#include <cstddef>
    1 | // Types used in iterator implementation -*- C++ -*-
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: error: 'ptrdiff_t' does not name a type
  214 |       typedef ptrdiff_t                   difference_type;
      |               ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:214:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: error: 'ptrdiff_t' does not name a type
  225 |       typedef ptrdiff_t                   difference_type;
      |               ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_types.h:225:15: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_algobase.h:66:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:112:5: error: 'ptrdiff_t' does not name a type
  112 |     ptrdiff_t
      |     ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:66:1: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
   65 | #include <debug/assertions.h>
  +++ |+#include <cstddef>
   66 | #include <bits/stl_iterator_base_types.h>
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: error: 'ptrdiff_t' does not name a type
  118 |     ptrdiff_t
      |     ^~~~~~~~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:118:5: note: 'ptrdiff_t' is defined in header '<cstddef>'; this is probably fixable by adding '#include <cstddef>'
In file included from /usr/include/c++/14/bits/stl_iterator.h:67,
                 from /usr/include/c+