#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int inf = 1e9 + 10;
const ld INF = 1e6;
const ld EPS = 1e-8;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

struct Point {
  long double x, y;

  Point(long double x = 0, long double y = 0): x(x), y(y) {}

  Point operator + (Point &p) {
    return Point(x + p.x, y + p.y);
  }

  Point operator - (Point &p) {
    return Point(x - p.x, y - p.y);
  }

  Point operator * (ld k) {
    return Point(x * k, y * k);
  }

  Point operator / (ld k) {
    return Point(x / k, y / k);
  }

  bool operator < (const Point &p) const {
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const {
    return fabs(x - p.x) < EPS && fabs(y - p.y) < EPS;
  }
};

long double norm(Point p) {
  return p.x * p.x + p.y * p.y;
}

long double dist(Point p) {
  return sqrt(norm(p));
}

long double dot(Point p1, Point p2) {
  return p1.x * p2.x + p1.y * p2.y;
}

long double cross(Point p1, Point p2) {
  return p1.x * p2.y - p1.y * p2.x;
}

Point rotate(Point p, ld theta) {
  return Point(p.x * cos(theta) - p.y * sin(theta), p.x * sin(theta) + p.y * cos(theta));
}

int ccw(Point p0, Point p1, Point p2) {
  Point v1 = p1 - p0, v2 = p2 - p0;
  if (cross(v1, v2) > 0) return 1;
  else if (cross(v1, v2) < 0) return -1;
  else if (dot(v1, v2) < 0) return 2;
  else if (norm(v1) < norm(v2)) return -2;
  else return 0;
}

bool intersect(Point p1, Point p2, Point p3, Point p4) {
  return (ccw(p1, p2, p3) * ccw(p1, p2, p4) <= 0 && ccw(p3, p4, p1) * ccw(p3, p4, p2) <= 0);
}

//直線p2-p1と点p3の距離
long double getDistanceLP(Point p1, Point p2, Point p3) {
  return fabs(cross(p2-p1, p3-p1) / dist(p2-p1));
}

//線分s(p2-p1)と点p3の距離
long double getDistanceSP(Point p1, Point p2, Point p3) {
  if (dot(p2-p1, p3-p1) < 0) return dist(p3-p1);
  else if (dot(p1-p2, p3-p2) < 0) return dist(p3-p2);
  else return getDistanceLP(p1, p2, p3);
}

//線分s1(p2-p1)と線分s2(p4-p3)の距離
long double getDistanceTS(Point p1, Point p2, Point p3, Point p4) {
  if (intersect(p1, p2, p3, p4)) return 0;
  long double ans = INF;
  ans = min(ans, getDistanceSP(p1, p2, p3));
  ans = min(ans, getDistanceSP(p1, p2, p4));
  ans = min(ans, getDistanceSP(p3, p4, p1));
  ans = min(ans, getDistanceSP(p3, p4, p2));
  return ans;
}

vector<Point> convex_hull(vector<Point>& ps, int n) {
  sort(ps.begin(), ps.end());
  int k = 0;
  vector<Point> qs(2 * n);
  rep(i, n) {
    while (k > 1 && cross(qs[k - 1] - qs[k - 2], ps[i] - qs[k - 1]) <= 0) k--;
    qs[k++] = ps[i];
  }
  for (int i = n - 2, t = k; i >= 0; i--) {
    while (k > t && (cross(qs[k - 1] - qs[k - 2], ps[i] - qs[k - 1]) <= 0)) k--;
    qs[k++] = ps[i];
  }
  qs.resize(k - 1);
  return qs;
}

struct Circle {
  Point p;
  long double r;

  Circle() {}
  Circle(Point p, ld r): p(p), r(r) {}
};

vector<Point> getIntersections(Circle c1, Circle c2) {
  ld d = dist(c2.p - c1.p);
  ld rc = (c1.r * c1.r + d * d - c2.r * c2.r) / (2 * d);
  ld rs = sqrt(c1.r * c1.r - rc * rc);
  Point e1 = (c2.p - c1.p) / d;
  Point e2 = rotate(e1, M_PI / 2) * rs;
  Point e3 = rotate(e1, -M_PI / 2) * rs;
  e1 = e1 * rc;
  Point a = c1.p + e1 + e2;
  Point b = c1.p + e1 + e3;
  return {a, b};
}

int main() {
  int n, k;
  cin >> n >> k;
  vector<Point> p(n);
  vector<ld> c(n);
  rep(i, n) cin >> p[i].x >> p[i].y >> c[i];

  ld left = 0, right = INF;
  while (right - left > EPS) {
    ld mid = (left + right) / 2;
    vector<Circle> r(n);
    rep(i, n) r[i] = Circle(p[i], mid / c[i]);
    bool f = false;
    rep(i, n) {
      if (f) break;
      int cnt = 0;
      rep(j, n) {
        if (dist(r[i].p - r[j].p) < r[j].r + EPS) cnt++;
      }
      if (cnt >= k) f = true;
    }
    rep(i, n) {
      rep(j, i) {
        if (f) break;
        if (fabs(r[i].r - r[j].r) - EPS < dist(r[i].p - r[j].p) && dist(r[i].p - r[j].p) < r[i].r + r[j].r + EPS) {
          vector<Point> res = getIntersections(r[i], r[j]);
          rep(l, 2) {
            int cnt = 0;
            rep(m, n) {
              if (dist(r[m].p - res[l]) < r[m].r + EPS) cnt++;
            }
            if (cnt >= k) f = true;
          }
        }
      }
    }
    if (f) right = mid;
    else left = mid;
  }
  cout << setprecision(15) << right << endl;

  
  return 0;
}


Measured memory_bytes: 256