#include <bits/stdc++.h>
using namespace std;
long double eps = 0.0000001;
int N, K;
vector<long double> X, Y, C;
pair<pair<long double, long double>, pair<long double, long double> > CLI(
    long double A, long double B, long double C, long double X1, long double Y1,
    long double R) {
  long double L = A * A + B * B;
  long double K = A * X1 + B * Y1 + C;
  long double D = L * R * R - K * K;
  long double Ds = sqrt(D + eps);
  long double ApL = A / L;
  long double BpL = B / L;
  long double XC = X1 - ApL * K;
  long double YC = Y1 - BpL * K;
  long double XD = BpL * Ds;
  long double YD = ApL * Ds;
  return {{XC - XD, YC + YD}, {XC + XD, YC - YD}};
}
pair<pair<long double, long double>, pair<long double, long double> > CCI(
    long double X1, long double Y1, long double R1, long double X2,
    long double Y2, long double R2) {
  long double A = X1 - X2;
  long double B = Y1 - Y2;
  return CLI(A, B,
             0.5 * ((R1 - R2) * (R1 + R2) - A * (X1 + X2) - B * (Y1 + Y2)), X1,
             Y1, R1);
}
long double Dist(long double X1, long double Y1, long double X2,
                 long double Y2) {
  return sqrt((X1 - X2) * (X1 - X2) + (Y1 - Y2) * (Y1 - Y2));
}
bool check(long double T) {
  bool check = false;
  for (int i = 0; i < N; i++) {
    int COUNT = 0;
    for (int j = 0; j < N; j++) {
      if (Dist(X[i], Y[i], X[j], Y[j]) * C[j] <= T + eps) COUNT++;
    }
    if (COUNT >= K) check = true;
  }
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (Dist(X[i], Y[i], X[j], Y[j]) > T / C[i] + T / C[j] + eps) continue;
      pair<pair<long double, long double>, pair<long double, long double> > Ps =
          CCI(X[i], Y[i], T / C[i], X[j], Y[j], T / C[j]);
      int COUNT = 0;
      for (int k = 0; k < N; k++) {
        if (Dist(Ps.first.first, Ps.first.second, X[k], Y[k]) * C[k] <= T + eps)
          COUNT++;
      }
      if (COUNT >= K) check = true;
      COUNT = 0;
      for (int k = 0; k < N; k++) {
        if (Dist(Ps.second.first, Ps.second.second, X[k], Y[k]) * C[k] <=
            T + eps)
          COUNT++;
      }
      if (COUNT >= K) check = true;
    }
  }
  return check;
}
int main() {
  cin >> N >> K;
  X.resize(N), Y.resize(N), C.resize(N);
  for (int i = 0; i < N; i++) cin >> X[i] >> Y[i] >> C[i];
  if (K == 1) {
    cout << 0 << endl;
    return 0;
  }
  long double L = 0.0, R = 200000.0;
  while (R - L > eps) {
    long double MID = (L + R) / 3;
    check(MID) ? R = MID : L = MID;
  }
  printf("%.12llf\n", L);
}
