#include <bits/stdc++.h>
using namespace std;

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/f.in", "r", stdin);
//  freopen("../IO/f.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

using real_t = double;
real_t EPS = 1e-6;

template <typename T>
struct point_t {
  T x, y;
  explicit point_t(T x = 0, T y = 0) : x(x), y(y) {}
  point_t &operator=(const point_t &A) = default;
  point_t operator+(const point_t &A) const { return point_t(x + A.x, y + A.y); }
  point_t operator-(const point_t &A) const { return point_t(x - A.x, y - A.y); }
  point_t operator*(const T &a) const { return point_t(x * a, y * a); }
  point_t operator/(const T &a) const { return point_t(x / a, y / a); }
  bool operator ==(const point_t &pt) const { return std::abs(x - pt.x) + std::abs(y - pt.y) < EPS; }
  void Print() const { std::cout << x << " " << y << '\n'; }
  T d2() const { return x * x + y * y; }
  real_t d() const { return std::sqrt(d2()); }
};

template<typename T>
T sqr(T x) { return x * x; };

struct circle_t {
  point_t<int64_t> origin;
  real_t radius;
  circle_t() = default;
  circle_t(const point_t<int64_t> &origin, real_t radius) : origin(origin), radius(radius) {}
  bool inside(const point_t<int64_t> &other) const {
    return (origin - other).d2() < radius * radius + EPS;
  }
  bool inside(const point_t<real_t> &other) const {
    return sqr(origin.x - other.x) + sqr(origin.y - other.y) < radius * radius + EPS;
  }
  bool intersect(const circle_t &other) const {
    int64_t d2 = (origin - other.origin).d2();
    return sqr(radius - other.radius) - 1e-9 <= d2 and d2 <= sqr(radius + other.radius) + 1e-9;
  }
};

pair<point_t<real_t>, point_t<real_t>> cccross(point_t<int64_t> O1, real_t r1, point_t<int64_t> O2, real_t r2) {
  int64_t d2 = (O1 - O2).d2();
  real_t d = (O1 - O2).d();
  real_t t = (d2 + r1 * r1 - r2 * r2) / (2 * d2);
  real_t fx = O1.x + (O2.x - O1.x) * t;
  real_t fy = O1.y + (O2.y - O1.y) * t;
  real_t h = std::sqrt(r1 * r1 - t * t * d2);
  real_t dx = (O2.y - O1.y) * h / d;
  real_t dy = (O1.x - O2.x) * h / d;
  return make_pair(point_t<real_t>(fx + dx, fy + dy), point_t<real_t>(fx - dx, fy - dy));
}

int n, k;
vector<point_t<int64_t>> origins;
vector<int> cs;

bool check(double T) {
  static vector<circle_t> circles(n);
  for (int i = 0; i < n; ++i) {
    circles[i].origin = origins[i];
    circles[i].radius = T / cs[i];
  }
  bool ok = false;
  for (auto origin : origins) {
    int count = 0;
    for (auto circle : circles) {
      count += circle.inside(origin);
    }
    if (count >= k) ok = true;
  }
  if (ok) return true;
  vector<point_t<real_t>> points;
  for (int i = 0; i < n; ++i) {
    for (int j = i + 1; j < n; ++j) {
      if (circles[i].intersect(circles[j])) {
        point_t<real_t> p1, p2;
        tie(p1, p2) = cccross(circles[i].origin, circles[i].radius, circles[j].origin, circles[j].radius);
        points.push_back(p1);
        points.push_back(p2);
      }
    }
  }
  for (point_t<real_t> point : points) {
    int count = 0;
    for (auto circle : circles) {
      count += circle.inside(point);
    }
    if (count >= k) ok = true;
  }
  return ok;
}

void solve(std::istream &in, std::ostream &out) {
  in >> n >> k;
  if (k == 1) {
    out << "0\n";
    return;
  }
  origins.resize(n);
  cs.resize(n);
  for (int i = 0; i < n; ++i) {
    in >> origins[i].x >> origins[i].y >> cs[i];
  }
  double left = 0, right = 1e9, eps = 1e-9;
  while (right - left > eps) {
    double mid = left + (right - left) / 2;
    if (check(mid)) {
      right = mid;
    } else {
      left = mid;
    }
  }
  out << fixed << setprecision(10);
  out << (right + left) / 2;
}


Measured memory_bytes: 512