#include <bits/stdc++.h>

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void puts_all(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void puts_all(const T &value, const Args&... args){std::cout << value << " ";puts_all(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



constexpr double eps = 1e-7;

template <typename T, typename U> bool EQ(const T &a, const U &b){return std::fabs(a-b) < eps;}
template <typename T, typename U> bool NE(const T &a, const U &b){return not EQ(a,b);}
template <typename T, typename U> bool LT(const T &a, const U &b){return a-b < -eps;}
template <typename T, typename U> bool LE(const T &a, const U &b){return a-b < eps;}
template <typename T, typename U> bool GT(const T &a, const U &b){return not LE(a,b);}
template <typename T, typename U> bool GE(const T &a, const U &b){return not LT(a,b);}

template <typename T> struct Point{
  T x, y;
  Point(): x(0), y(0){}
  Point(const T &x, const T &y): x(x), y(y){}
  T size() const {return sqrt(x*x+y*y);}
  T size_sq() const {return x*x+y*y;}
  
  static Point<T> polar(const T &r, const T &ang){return Point(r * cos(ang), r * sin(ang));}
};

template <typename T> auto operator+(const Point<T> &a, const Point<T> &b){return Point<T>(a.x+b.x, a.y+b.y);}
template <typename T> auto operator-(const Point<T> &a, const Point<T> &b){return Point<T>(a.x-b.x, a.y-b.y);}
template <typename T> auto operator-(const Point<T> &a){return Point<T>(-a.x, -a.y);}
template <typename T, typename U> auto operator*(const Point<T> &a, const U &k){return Point<T>(a.x*k, a.y*k);}
template <typename T, typename U> auto operator*(const U &k, const Point<T> &a){return Point<T>(a.x*k, a.y*k);}
template <typename T, typename U> auto operator/(const Point<T> &a, const U &k){return Point<T>(a.x/k, a.y/k);}

template <typename T> bool operator==(const Point<T> &a, const Point<T> &b){return EQ(a.x,b.x) and EQ(a.y,b.y);}
template <typename T> bool operator!=(const Point<T> &a, const Point<T> &b){return !(a==b);}
template <typename T> bool operator<(const Point<T> &a, const Point<T> &b){return LT(a.x,b.x) or (EQ(a.x,b.x) and LT(a.y,b.y));}

template <typename T> std::istream& operator>>(std::istream &is, Point<T> &a){is >> a.x >> a.y; return is;}
template <typename T> std::ostream& operator<<(std::ostream &os, const Point<T> &a){os << "(" << a.x << "," << a.y << ")"; return os;}

template <typename T> T dot(const Point<T> &a, const Point<T> &b){return a.x*b.x+a.y*b.y;}
template <typename T> T cross(const Point<T> &a, const Point<T> &b){return a.x*b.y-a.y*b.x;}
template <typename T> T angle(const Point<T> &a, const Point<T> &b){return std::atan2(b.y-a.y, b.x-a.x);} // 点aから点bへの角度
template <typename T> auto unit(const Point<T> &a){return a / a.size();} // 単位ベクトル
template <typename T> auto normal(const Point<T> &p){return Point<T>(-p.y,p.x);}
template <typename T> T phase(const Point<T> &a){return std::atan2(a.y, a.x);}

template <typename T>
T angle_diff(const Point<T> &a, const Point<T> &b){
  T r = phase(b) - phase(a);

  if(r < -M_PI) return r + 2 * M_PI;
  else if(r > M_PI) return r - 2 * M_PI;
  return r;
}

template <typename T> struct Line{
  Point<T> from, to;
  Line(): from(), to(){}
  Line(const Point<T> &from, const Point<T> &to): from(from), to(to){}
  Point<T> diff() const {return to-from;}
  T size() const {return diff().size();}
};

template <typename T> using Segment = Line<T>;
template <typename T> using Polygon = std::vector<Point<T>>;

template <typename T> struct Circle{
  Point<T> center;
  T radius;
  Circle(): center(), radius(0){}
  Circle(const Point<T> &center, T radius): center(center), radius(radius){}
};



namespace intersect_circles{
  enum Status{
              SAME          = 0b000001,
              INSIDE        = 0b000010,
              INSCRIBED     = 0b000100,
              INTERSECT     = 0b001000,
              CIRCUMSCRIBED = 0b010000,
              OUTSIDE       = 0b100000
  };
  
  template <typename T>
  Status check(const Circle<T> &a, const Circle<T> &b, std::vector<Point<T>> &ret){
    const T d = (a.center - b.center).size();
    const T x = acos((a.radius * a.radius + d * d - b.radius * b.radius) / (2.0 * d * a.radius));
    const T t = atan2(b.center.y - a.center.y, b.center.x - a.center.x);
  
    if(EQ(a.radius + b.radius, d)){
      ret = {a.center + Point<T>::polar(a.radius, t)}; // if circumscribed
      return CIRCUMSCRIBED;
    }
    else if(EQ(std::fabs(a.radius-b.radius), d)){
      ret = {a.center + Point<T>::polar(a.radius,t)}; // if inscribed
      return INSCRIBED;
    }
    else if(GT(a.radius+b.radius, d) and GT(d, std::fabs(a.radius-b.radius))){// if intersect
      ret = {
             a.center + Point<T>::polar(a.radius,t+x),
             a.center + Point<T>::polar(a.radius,t-x)
      };
      return INTERSECT;
    }
    else if(LT(a.radius+b.radius, d)){
      return OUTSIDE;
    }
    else if(GT(std::fabs(a.radius-b.radius), d)){
      return INSIDE;
    }
    else{
      return SAME;
    }
  }

  template <typename T>
  Status check(const Circle<T> &a, const Circle<T> &b){
    std::vector<Point<T>> c;
    return check(a, b, c);
  }
}



using Pt = Point<double>;
using Cr = Circle<double>;

int main(){
  int N, K;

  while(cin >> N >> K){
    vector<Pt> ps(N);
    vector<int> c(N);
    REP(i,N) cin >> ps[i] >> c[i];


    auto f =
      [&](double T){
        vector<Pt> a(ps);

        vector<Cr> crs(N);
        REP(i,N) crs[i] = Cr(ps[i], T / c[i]);

        REP(i,N){
          FOR(j,i+1,N){
            vector<Pt> res;
            intersect_circles::check(crs[i], crs[j], res);
            a.insert(a.end(), ALL(res));
          }
        }

        for(auto &p : a){
          int count = 0;

          for(auto &C : crs){
            if(LE((C.center-p).size(), C.radius)) ++count;
          }

          if(count >= K) return true;
        }
        

        return false;
      };

    
    double lb = 0, ub = 1000000;
    REP(i,200){
      double mid = (lb + ub) / 2;

      if(f(mid)){
        ub = mid;
      }else{
        lb = mid;
      }
    }

    puts_all(lb);
  }

  return 0;
}


Measured memory_bytes: 1148