/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author aajisaka
 */

#include<bits/stdc++.h>

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

constexpr long double PI = 3.14159265358979323846264338327950288L;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
double eps = 1e-10;
double add(double a, double b) {
  if (abs(a+b) < eps*(abs(a) + abs(b))) return 0;
  return a+b;
}

struct Point {
    double x, y;
    Point()= default;
    Point(double x, double y) : x(x), y(y) {}
    Point operator+(Point p) { return {add(x, p.x), add(y, p.y)};}
    Point operator-(Point p) { return {add(x, -p.x), add(y, -p.y)};}
    Point operator*(double d) { return {x*d, y*d};}
    Point operator/(double d) { return {x/d, y/d};}
    double dot(Point p) { return add(x*p.x, y*p.y);}
    double det(Point p) { return add(x*p.y, -y*p.x);}
    double dist(Point a){return (*this-a).norm();}
    double norm() {return sqrt(x*x+y*y);}

    // return true if q exists on a line segment [p1, p2]
    static bool on_seg(Point p1, Point p2, Point q) {
      return (p1-q).det(p2-q) == 0 && (p1-q).dot(p2-q) <= 0;
    }
    // return intersection of two lines (p1, p2), (q1, q2)
    static Point intersection(Point p1, Point p2, Point q1, Point q2) {
      return p1 + (p2-p1)*((q2-q1).det(q1-p1)/(q2-q1).det(p2-p1));
    }
};

// return true if the two line segment [p1, p2], [q1, q2] is intersected
static bool is_intersected(Point p1, Point p2, Point q1, Point q2) {
  return (p2-p1).det(q1-p1) * (p2-p1).det(q2-p1) < 0 &&
         (q2-q1).det(p1-q1) * (q2-q1).det(p2-q1) < 0;
}

int sgn(double a, double b=0){return a<b-eps?-1:a>b+eps?1:0;}

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

    bool contain(Point a){
      return sgn((a-p).norm(),r)<=0;
    }

    // Return the minimum circum-circle of the 2 points.
    Circle circumCircle(Point a,Point b){
      Point q=(a+b)/2;
      return Circle(q,(a-q).norm());
    }

    // Return the circum-circle of the 3 points.
    Circle circumscribedCircle(Point p, Point q, Point r){
      Point a=(q-p)*2,b=(r-p)*2;
      Point c(p.dot(p)-q.dot(q),p.dot(p)-r.dot(r));
      Circle res;
      res.p.x=a.y*c.y-b.y*c.x;
      res.p.y=b.x*c.x-a.x*c.y;
      res.p=res.p/a.det(b);
      return Circle(res.p, p.dist(res.p));
    }

    // Return the minimum enclosing circle in O(ps.size()).
    // The input should be shuffled.
    Circle minEnclosingCircle(vector<Point>ps){
      if(ps.size()==0)return Circle(Point(0,0),0);
      if(ps.size()==1)return Circle(ps[0],0);

      Circle circle=circumCircle(ps[0],ps[1]);
      for(int i=2;i<ps.size();i++){
        if(!circle.contain(ps[i])){
          circle=circumCircle(ps[0],ps[i]);
          for(int j=1;j<i;j++){
            if(!circle.contain(ps[j])){
              circle=circumCircle(ps[j],ps[i]);
              for(int k=0;k<j;k++){
                if(!circle.contain(ps[k])){
                  circle=circumscribedCircle(ps[i],ps[j],ps[k]);
                }
              }
            }
          }
        }
      }
      return circle;
    }

    // Return if the two circle is crossed
    static bool crossed(Circle c1, Circle c2) {
      double d = (c1.p-c2.p).norm();
      double rc = (d*d + c1.r*c1.r - c2.r*c2.r) / (2*d);
      return c1.r*c1.r - rc*rc >= 0;
    }

    // Return two cross points
    static pair<Point, Point> cross(Circle c1, Circle c2) {
      double d = (c1.p-c2.p).norm();
      double rc = (d*d + c1.r*c1.r - c2.r*c2.r) / (2*d);
      double rs = sqrt(c1.r*c1.r - rc*rc);
      Point diff = (c2.p - c1.p) / d;
      Point diff90 = Point(diff.y, -diff.x);
      return make_pair(c1.p + diff*rc + diff90*rs, c1.p + diff*rc - diff90*rs);
    }
};


class FYakinikuOptimizationProblem {
public:
    void solve(istream& cin, ostream& cout) {
      SPEED;
      int n, K; cin >> n >> K;
      if (K==1) {
        cout << 0 << endl;
        return;
      }

      vector<int> x(n), y(n), c(n);
      rep(i, n) {
        cin >> x[i] >> y[i] >> c[i];
      }

      auto ans = DBL_MAX;

      if (K >= 3) {
        double ng = 0;
        double ok = 1e+9;
        rep(_, 100) {
          double med = (ng+ok)/2;
          vector<Circle> vc(n);
          rep(i, n) {
            vc[i] = Circle(Point(x[i], y[i]), med/c[i]);
          }
          vector<Point> vp;
          rep(i, n) {
            vp.emplace_back(x[i], y[i]);
          }
          rep(i, n) {
            for(int j=i+1; j<n; j++) {
              if (Circle::crossed(vc[i], vc[j])) {
                auto pa = Circle::cross(vc[i], vc[j]);
                vp.push_back(pa.first);
                vp.push_back(pa.second);
              }
            }
          }
          bool flag = false;
          for(auto e: vp) {
            int cnt = 0;
            rep(i, n) {
              if (vc[i].contain(e)) cnt++;
            }
            if (cnt >= K) {
              flag = true;
              break;
            }
          }
          if (flag) {
            ok = med;
          } else {
            ng = med;
          }
        }
        chmin(ans, ok);
      } else if (K==2) {
        rep(i, n) {
          for(int j=i+1; j<n; j++) {
            Point p1 = Point(x[i], y[i]);
            Point p2 = Point(x[j], y[j]);
            int c1 = c[i];
            int c2 = c[j];
            Point h = p1 + (p2-p1)*c2/(c1+c2);
            double time = (h-p1).norm()*c1;
            chmin(ans, time);
          }
        }
      }

      cout << setprecision(10) << fixed;
      cout << ans << endl;


    }
};

signed main() {
  FYakinikuOptimizationProblem solver;
  std::istream& in(std::cin);
  std::ostream& out(std::cout);
  solver.solve(in, out);
  return 0;
}

Measured memory_bytes: 384