#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<double, double> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;
typedef tuple<ll, ll, ll, ll, ll> t5;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

using namespace std;

static const ll INF = 1e15;

template<typename T>
static inline void chmax(T& ref, const T value) {
	if (ref < value) ref = value;
}

const ll mod = 1000000007;

struct vector2d {
	double x, y;
	vector2d() :x(0), y(0) {}
	vector2d(double x, double y) : x(x), y(y) {}

	static double distanceSquare(const vector2d& v1, const vector2d& v2) {
		double dx = v1.x - v2.x;
		double dy = v1.y - v2.y;
		return dx * dx + dy * dy;
	}

	static double distance(const vector2d& v1, const vector2d& v2) {
		return sqrt(distanceSquare(v1, v2));
	}

	vector2d sub(vector2d p2) const {
		return vector2d(x - p2.x, y - p2.y);
	}

	vector2d add(vector2d p2) const {
		return vector2d(x + p2.x, y + p2.y);
	}

	double distance(vector2d p2) const {
		return sqrt((x - p2.x) * (x - p2.x) + (y - p2.y) * (y - p2.y));
	}

	double norm() const {
		double length = sqrt(x * x + y * y);
		return length;
	}

	vector2d normal() const {
		double length = norm();
		return vector2d(x / length, y / length);
	}

	vector2d scale(double s) const {
		return vector2d(x * s, y * s);
	}

	vector2d operator+(const vector2d& p) const { return vector2d(x + p.x, y + p.y); }
	vector2d operator-(const vector2d& p) const { return vector2d(x - p.x, y - p.y); }
	vector2d operator*(double a) const { return vector2d(x * a, y * a); }
	vector2d Rot90() const { return { -y, x }; }
};

struct circle2d {
	vector2d center;
	double radius;

	circle2d(double x, double y, double r) {
		center = { x,y };
		radius = r;
	}

	std::vector<vector2d> Intersections(const circle2d& c) const {
		auto sq = [](double x) -> double { return x * x; };
		vector2d v = c.center.sub(center);
		auto l = v.norm();
		if (l >= radius + c.radius || (l + radius) <= c.radius ||
			(l + c.radius) <= radius) {
			return {};
		}
		auto x = (sq(radius) - sq(c.radius) + sq(l)) / (2 * l);
		auto a = std::sqrt(sq(radius) - sq(x));
		auto perpendicular_foot = v.scale(x / l);
		auto perpendicular = v.Rot90().scale(a / l);
		return { center.add(perpendicular_foot).add(perpendicular),
				center.add(perpendicular_foot).sub(perpendicular) };
	}
};

int main() {
	ll n, k;
	cin >> n >> k;
	vector<double> xs(n);
	vector<double> ys(n);
	vector<double> cs(n);
	rep(i, n) {
		cin >> xs[i] >> ys[i] >> cs[i];
	}
	if (k == 1) {
		cout << 0 << endl;
		return 0;
	}
	double left = 0; double right = 100 * 8000;
	double m;
	while (right - left > 1e-8) {
		m = left + right;
		m /= 2;
		vector<double> rs(n);
		rep(i, n) {
			rs[i] = m / cs[i];
		}
		vector<vector2d> intersections;
		rep(i, n) {
			intersections.emplace_back(xs[i], ys[i]);
		}
		for (int i = 0; i < n; i++) {
			circle2d a(xs[i], ys[i], rs[i]);
			for (int j = i + 1; j < n; j++) {
				circle2d b(xs[j], ys[j], rs[j]);
				vector<vector2d> v;
				v = a.Intersections(b);
				if (v.size()) {
					intersections.emplace_back(v[0]);
					intersections.emplace_back(v[1]);
					intersections.emplace_back(((v[0].add(v[1])).scale(0.5)));
				}
			}
		}
		int count = 0;
		for (auto p : intersections) {
			count = 0;
			//cout << p.x << "," << p.y << endl;
			for (int i = 0; i < n; i++) {
				double d = p.distance({ xs[i], ys[i] });
				if (d <= rs[i] + 1e-10) {
					count++;
				}
			}
			if (count >= k) {
				break;
			}
		}
		//cout << m << "," << count << endl;
		if (count >= k) {
			right = m;
		}
		else {
			left = m;
		}
	}
	cout << fixed << setprecision(10);
	cout << right << endl;
	return 0;
}


Measured memory_bytes: 3912