#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)

const double eps = 1e-10;
const double inf = 1e+10;
const double pi = acos(-1.0);

struct Point {
  double x, y;
  Point(double x = 0.0, double y = 0.0) : x(x), y(y) {}  
  double norm() {return sqrt(x*x + y*y);}
};

Point operator + (const Point &p, const Point &q) {return Point(p.x + q.x, p.y + q.y);}
Point operator - (const Point &p, const Point &q) {return Point(p.x - q.x, p.y - q.y);}
double operator * (const Point &p, const Point q) {return p.x * q.x + p.y * q.y;}
bool operator == (const Point &p, const Point &q) {return (abs(p.x - q.x) < eps && abs(p.y - q.y) < eps);}
bool operator != (const Point &p, const Point &q) {return !(p == q);}
double cross(const Point &p, const Point &q) {return p.x*q.y - p.y*q.x;}
double dist(const Point &p, const Point &q) {return (p-q).norm();}
bool compx(const Point &p, const Point &q) {return p.x != q.x? p.x < q.x : p.y < q.y;}
bool compy(const Point &p, const Point &q) {return p.y != q.y? p.y < q.y : p.x < q.x;}

struct Line {
  double a, b, c;
  Line(double a, double b, double c) : a(a), b(b), c(c) {}
  Line(Point p, Point q) {
    a = q.y - p.y;
    b = p.x - q.x;
    c = q.x * p.y - p.x * q.y;
  }
};

struct Circle {
  double r;
  Point p;
  Circle(Point p = Point(0.0, 0.0), double r = 0.0) : p(p), r(r) {}
};

// 点の直線への射影
Point projection (Point p, Line l) {
  double x = p.x - l.a * (l.a*p.x + l.b*p.y + l.c) / (l.a*l.a + l.b*l.b);
  double y = p.y - l.b * (l.a*p.x + l.b*p.y + l.c) / (l.a*l.a + l.b*l.b);
  return Point(x,y);
}

// ★円と直線の交点
vector<Point> circle_line_cross(Circle c, Line l) {
  vector<Point> vp;
  Point h = projection(c.p,l);

  double d = l.a*c.p.x + l.b*c.p.y + l.c;
  double q = c.r*c.r - d*d / (l.a*l.a + l.b*l.b);
  if(q >= eps) {
    Point p1, p2;
    p1.x = h.x + sqrt(q) * l.b / sqrt(l.a*l.a + l.b*l.b);
    p1.y = h.y - sqrt(q) * l.a / sqrt(l.a*l.a + l.b*l.b);
    p2.x = h.x - sqrt(q) * l.b / sqrt(l.a*l.a + l.b*l.b);
    p2.y = h.y + sqrt(q) * l.a / sqrt(l.a*l.a + l.b*l.b);
    vp.push_back(p1);
    vp.push_back(p2);
  } else if(abs(q) < eps) {
    vp.push_back(h);
  }
  return vp;
} 

// ★円と円の交差判定 (離れる:4 外接:3 交わる:2 内接:1 内包:0)
int circle_circle_pos(Circle c, Circle d) {
  if(dist(c.p,d.p) >= c.r + d.r + eps) return 4;
  else if(abs(dist(c.p,d.p) - c.r - d.r) < eps) return 3;
  else if(dist(c.p,d.p) >= abs(c.r-d.r) + eps) return 2;
  else if(abs(dist(c.p,d.p) - abs(c.r-d.r)) < eps) return 1;
  else return 0; 
}

// ★円と円の交点
vector<Point> circle_circle_cross(Circle c, Circle d) {
  if(circle_circle_pos(c,d)) {
    Line l(2.0*(c.p.x-d.p.x),2.0*(c.p.y-d.p.y),-c.p.x*c.p.x+d.p.x*d.p.x-c.p.y*c.p.y+d.p.y*d.p.y+c.r*c.r-d.r*d.r);
    return circle_line_cross(c,l);
  } else {
    return vector<Point>();
  }
}

int main() {
  int n, k;
  cin >> n >> k;
  Point p[n]; double c[n];
  rep(i,n) cin >> p[i].x >> p[i].y >> c[i];
  double l = 0.0, r = inf;
  while(r-l > 1e-9) {
    double m = (l+r)/2;
    bool f = false;
    rep(i,n) {
      int t = 0;
      rep(j,n) {
        if(dist(p[i],p[j]) <= m/c[j] + eps) t++; 
      }
      if(t >= k) f = true;
    }
    rep(i,n) {
      for(int j = 1; j < n; j++) {
        vector<Point> v = circle_circle_cross(Circle(p[i],m/c[i]),Circle(p[j],m/c[j]));
        for(auto q : v) {
          int t = 0;
          rep(h,n) {
            if(dist(q,p[h]) <= m/c[h] + eps) t++; 
          }
          if(t >= k) f = true;
        }
      }
    }
    f ? r = m: l = m;
  }
  printf("%.9lf\n",l);
}

Measured memory_bytes: 384