#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e5 + 5;
const int MOD = 998244353;
int n, k;
struct node {
  double x, y, c, r;
} a[MAXN];
vector<pair<double, double> > v;
vector<pair<double, double> > cal(double x1, double y1, double r1, double x2,
                                  double y2, double r2) {
  x1 -= x2, y1 -= y2;
  double S = x1 * x1 + y1 * y1, a = (S + r2 * r2 - r1 * r1) / 2,
         D = S * r2 * r2 - a * a;
  if (D < 0) return {};
  double A1 = a * x1, B1 = y1 * sqrt(D);
  double A2 = a * y1, B2 = x1 * sqrt(D);
  return {{(A1 + B1) / S + x2, (A2 - B2) / S + y2},
          {(A1 - B1) / S + x2, (A2 + B2) / S + y2}};
}
bool check(double t) {
  for (int i = 1; i <= n; i++) a[i].r = t / a[i].c;
  v.clear();
  for (int i = 1; i <= n; i++) {
    v.push_back(make_pair(a[i].x, a[i].y));
    for (int j = i + 1; j <= n; j++) {
      auto p = cal(a[i].x, a[i].y, a[i].r, a[j].x, a[j].y, a[j].r);
      for (auto it : p) {
        v.push_back(it);
      }
    }
  }
  int len = v.size();
  for (int i = 0; i <= len - 1; i++) {
    pair<double, double> p = v[i];
    int num = 0;
    for (int i = 1; i <= n; i++) {
      if ((a[i].x - p.first) * (a[i].x - p.first) +
                  (a[i].y - p.second) * (a[i].y - p.second) <=
              a[i].r * a[i].r ||
          fabs((a[i].x - p.first) * (a[i].x - p.first) +
               (a[i].y - p.second) * (a[i].y - p.second) - a[i].r * a[i].r) <=
              1e-9)
        num++;
      if (num == k) return 1;
    }
  }
  return 0;
}
int main() {
  while (cin >> n >> k) {
    for (int i = 1; i <= n; i++) cin >> a[i].x >> a[i].y >> a[i].c;
    double l = 0, r = 1e9;
    for (int i = 1; i <= 100; i++) {
      double mid = (l + r) / 2;
      if (check(mid))
        r = mid;
      else
        l = mid;
    }
    printf("%.10lf\n", r);
  }
}
