#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define REP(i, n) for(int i=0;i<(n);++i)
#define RANGE(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(n)-1;i>= 0;--i)

#define endl '\n'
#define pb push_back
#define eb emplace_back
#define pque priority_queue
#define umap unordered_map
#define uset unordered_set
#define BIG 2000000000
#define VERYBIG 1000000000000000ll
#define dcout cout<<fixed<<setprecision(50)
#define _popcnt __builtin_popcount

constexpr long long dx[]={1,0,-1,0,1,1,-1,-1}, dy[]={0,-1,0,1,1,-1,1,-1};
constexpr long long MOD = 1e9+7;

// typedef long long lint;
#define int long long
// #define double long double

template<typename T> inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template<typename T> inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template<typename T> inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template<typename T> inline T nHr(T a,T b){return nCr(a+b-1,b);}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

typedef pair<int, int> INTP;
typedef vector<int> INTV;
struct edge2 {int to, cost;};
struct edge3 {int from, to, cost;};

using Point = complex<double>;
using Real = long double;
const Real eps = 1e-9, pi = acos(-1);

inline bool eq(Real a, Real b) {return fabs(b - a) < eps;}

istream &operator>> (istream &is, Point &p){
  Real a, b;
  is >> a >> b;
  p = Point(a, b);
  return is;
}

struct Circle {
  Point p; Real r;
  Circle(Point p = Point(0.0, 0.0), Real r = 0.0) : p(p), r(r){}
};

int checker(Circle c1, Circle c2){
  if(c1.r < c2.r) swap(c1, c2);
  Real d = abs(c1.p - c2.p);
  if(c1.r + c2.r < d) return 4;
  if(eq(c1.r + c2.r, d)) return 3;
  if(c1.r - c2.r < d) return 2;
  if(eq(c1.r - c2.r, d)) return 1;
  return 0;
}

bool intersect(const Circle &c1, const Circle &c2){
  int tmp = checker(c1, c2);
  return 1 <= tmp and tmp <= 3;
}

pair< Point, Point > crosspoint(const Circle &c1, const Circle &c2){
  Real d = abs(c1.p - c2.p);
  Real a = acos((c1.r*c1.r + d*d - c2.r*c2.r) / (2 * c1.r * d)); // 余弦定理
  Real t = atan2(c2.p.imag() - c1.p.imag(), c2.p.real() - c1.p.real());
  Point p1 = c1.p + Point(cos(t+a) * c1.r, sin(t+a) * c1.r);
  Point p2 = c1.p + Point(cos(t-a) * c1.r, sin(t-a) * c1.r);
  return {p1, p2};
}
using Points = vector<Point>;
using Circles = vector<Circle>;

signed main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);

  int N, K; cin >> N >> K;
  Points P(N); vector<Real> C(N);
  REP(i, N) cin >> P[i] >> C[i];

  Real left = 0.0, right = 300000.0;
  REP(_, 40){
    Real R = (left+right) / 2.0;
    Points alt;
    Circles cs;
    REP(i, N) cs.pb(Circle(P[i], R/C[i]));
    REP(i, N) {
      alt.pb(P[i]);
      RANGE(j, i+1, N){
        if(!intersect(cs[i], cs[j])) continue;
        pair<Point, Point> cross = crosspoint(cs[i], cs[j]);
        alt.pb(cross.first); alt.pb(cross.second);
      }
    }
    bool ok = 0;
    for(auto pt : alt){
      int cnt = 0;
      REP(i, N){
        if(abs(pt - P[i]) <= R/C[i] + eps) cnt++;
      }
      if(cnt >= K) ok |= 1;
    }
    if(ok) right = R;
    else left = R;
  }
  dcout << right << endl;
}

Measured memory_bytes: 640