// Original C++ solution (slower):
#include <bits/stdc++.h>



int ri() {

	int n;

	scanf("%d", &n);

	return n;

}

#define EPS 1e-9

constexpr double PI = acos(-1);

int main() {

	struct Point {

		double x;

		double y;

	};

	int n = ri(), k = ri();

	Point pts[n];

	int c[n];

	for (int i = 0; i < n; i++) pts[i].x = ri(), pts[i].y = ri(), c[i] = ri();

	if (k == 1) {

		puts("0");

		return 0;

	}

	double l = 0, r = 300000;

	for (int i = 0; i < 40; i++) {

		double m = (l + r) / 2;

		double radius[n];

		for (int j = 0; j < n; j++) radius[j] = m / c[j];

		auto dist = [] (Point p0, Point p1) { return std::hypot(p0.x - p1.x, p0.y - p1.y); };

		Point res0, res1;

		int max = 0;

		auto kosa = [&] (Point p0, double r0, Point p1, double r1) {

			if (dist(p0, p1) > r0 + r1) return false;

			double base_atan2 = std::atan2(p1.y - p0.y, p1.x - p0.x);

			if (base_atan2 < 0) base_atan2 += 2 * PI;

			auto pos = [&] (double kakudo) {

				return Point{p0.x + std::cos(kakudo) * r0, p0.y + std::sin(kakudo) * r0};

			};

			auto opp = pos(base_atan2 + PI);

			if (dist(opp, p1) <= r1) return false;

			

			double upper, lower;

			{

				double l = base_atan2;

				double r = base_atan2 + PI;

				for (int i = 0; i < 60; i++) {

					double m = (l + r) / 2;

					if (dist(pos(m), p1) <= r1) l = m;

					else r = m;

				}

				upper = l;

			}{

				double l = base_atan2 - PI;

				double r = base_atan2;

				for (int i = 0; i < 60; i++) {

					double m = (l + r) / 2;

					if (dist(pos(m), p1) <= r1) l = m;

					else r = m;

				}

				lower = l;

			}

			res0 = pos(upper);

			res1 = pos(lower);

			return true;

		};

		auto try_pt = [&] (Point pt) {

			int cnt = 0;

			for (int i = 0; i < n; i++) if (dist(pts[i], pt) <= radius[i] + EPS) cnt++;

			max = std::max(max, cnt);

		};

		for (int j = 0; j < n; j++) {

			for (int k = 0; k < j; k++) {

				if (kosa(pts[j], radius[j], pts[k], radius[k])) try_pt(res0), try_pt(res1);

			}

		}

		for (int j = 0; j < n; j++) try_pt(pts[j]);

		if (max >= k) r = m;

		else l = m;

	}

	printf("%.11f\n", l);

	return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



int ri() {

	int n;

	scanf("%d", &n);

	return n;

}

#define EPS 1e-9

constexpr double PI = acos(-1);

int main() {

	struct Point {

		double x;

		double y;

	};

	int n = ri(), k = ri();

	Point pts[n];

	int c[n];

	for (int i = 0; i < n; i++) pts[i].x = ri(), pts[i].y = ri(), c[i] = ri();

	if (k == 1) {

		puts("0");

		return 0;

	}

	double l = 0, r = 300000;

	for (int i = 0; i < 40; i++) {

		double m = (l + r) / 2;

		double radius[n];

		for (int j = 0; j < n; j++) radius[j] = m / c[j];

		auto dist = [] (Point p0, Point p1) { return std::hypot(p0.x - p1.x, p0.y - p1.y); };

		Point res0, res1;

		int max = 0;

		auto kosa = [&] (Point p0, double r0, Point p1, double r1) {

			if (dist(p0, p1) > r0 + r1) return false;

			double base_atan2 = std::atan2(p1.y - p0.y, p1.x - p0.x);

			if (base_atan2 < 0) base_atan2 += 2 * PI;

			auto pos = [&] (double kakudo) {

				return Point{p0.x + std::cos(kakudo) * r0, p0.y + std::sin(kakudo) * r0};

			};

			auto opp = pos(base_atan2 + PI);

			if (dist(opp, p1) <= r1) return false;

			

			double upper, lower;

			{

				double l = base_atan2;

				double r = base_atan2 + PI;

				for (int i = 0; i < 20; i++) {

					double m = (l + r) / 2;

					if (dist(pos(m), p1) <= r1) l = m;

					else r = m;

				}

				upper = l;

			}{

				double l = base_atan2 - PI;

				double r = base_atan2;

				for (int i = 0; i < 20; i++) {

					double m = (l + r) / 2;

					if (dist(pos(m), p1) <= r1) l = m;

					else r = m;

				}

				lower = l;

			}

			res0 = pos(upper);

			res1 = pos(lower);

			return true;

		};

		auto try_pt = [&] (Point pt) {

			int cnt = 0;

			for (int i = 0; i < n; i++) if (dist(pts[i], pt) <= radius[i] + EPS) cnt++;

			max = std::max(max, cnt);

		};

		for (int j = 0; j < n; j++) {

			for (int k = 0; k < j; k++) {

				if (kosa(pts[j], radius[j], pts[k], radius[k])) try_pt(res0), try_pt(res1);

			}

		}

		for (int j = 0; j < n; j++) try_pt(pts[j]);

		if (max >= k) r = m;

		else l = m;

	}

	printf("%.11f\n", l);

	return 0;

}


// Fastest known solution for this problem: