#include <bits/stdc++.h>
using namespace std;

#define NDEBUG
#include <cassert>


typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<Double,Double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<llll> vllll;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<Double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
#define cons make_pair
#define clamp(v,lo,hi) min(max(v,lo),hi)


template<typename T1, typename T2> inline void amin(T1 & a, T2 const & b) { if (a>b) a=b; }
template<typename T1, typename T2> inline void amax(T1 & a, T2 const & b) { if (a<b) a=b; }
template<typename X, typename T> auto vectors(X x, T a) { return vector<T>(x, a); }
template<typename X, typename Y, typename Z, typename... Zs> auto vectors(X x, Y y, Z z, Zs... zs) { auto cont = vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }

inline Double square(Double x) { return x * x; }
inline ll gcd(ll a, ll b) { while(a) swap(a, b%=a); return b; }
template <typename T>
inline T mod(T a, T b) { return ((a % b) + b) % b; }


#define INTSPACE 12
char _buf[INTSPACE*1000000 + 3];



int N, K;
vi x,y,c;
vector<Double> x2, y2, c2;


using DD = pair<Double,Double>;

bool cross(Double x0,Double y0,Double r0, Double x1,Double y1,Double r1, Double& mx1, Double& my1, Double& mx2, Double& my2){
/*
    (X - x0)^2 + (Y - y0)^2 = r0^2
    (X - x1)^2 + (Y - y1)^2 = r1^2
    X^2 - 2Xx0 + x0^2 + Y^2 - 2Yy0 + y0^2 = r0^2
  -)X^2 - 2Xx1 + x1^2 + Y^2 - 2Yy1 + y1^2 = r1^2
    - 2X(x0-x1) + (x0^2-x1^2) + -2Y(y0-y1) + (y0^2-y1^2) = r0^2-r1^2
    2(x0-x1)X + 2(y0-y1)Y = (x0^2-x1^2) + (y0^2-y1^2) - (r0^2-r1^2)

*/
    Double dx = x1-x0, dy = y1-y0, k = hypotl(dx,dy);
    if (k > r0+r1) return false;
    if (k+r0 < r1) {
        mx1 = mx2 = x0;
        my1 = my2 = y0;
        return true;
    }
    if (k+r1 < r0) {
        mx1 = mx2 = x1;
        my1 = my2 = y1;
        return true;
    }

    Double x = (square(r0) - square(r1) + square(k)) / (k*2);
    Double rat = x / k;
    Double mx = x0 + dx * rat, my = y0 + dy * rat;

    Double ux = dy / k, uy = -dx / k;
    Double w = sqrtl(square(r0) - square(x));
    mx1 = mx + ux * w, my1 = my + uy * w;
    mx2 = mx - ux * w, my2 = my - uy * w;
    return true;
}


Double solve(){
    if (N == 1) return 0;

    Double lo=0, hi=1000000;
    while ((hi-lo) > 1e-8) {
        Double mi = (lo+hi)/2;
        vector<Double> r(N);
        rep(i,N){ r[i] = mi / c[i]; }

        vector<DD> points;
        Double best = INT_MAX;

        rep(i,N){
            points.emplace_back(x[i], y[i]);
        }
        repC2(i,j,N){
            points.emplace_back((x[i]*r[j] + x[j]*r[i])/(r[i]+r[j]),
                                (y[i]*r[j] + y[j]*r[i])/(r[i]+r[j]));
            points.emplace_back((x[i]*c[j] + x[j]*c[i])/(c[i]+c[j]),
                                (y[i]*c[j] + y[j]*c[i])/(c[i]+c[j]));

            Double mx1,my1, mx2,my2;
            if (!cross(x[i],y[i],r[i], x[j],y[j],r[j], mx1,my1, mx2,my2)) continue;
            points.emplace_back(mx1,my1);
            points.emplace_back((mx1+mx2)/2,(my1+my2)/2);
            points.emplace_back(mx2,my2);
        }

        bool ok=false;
        for(DD& pt : points){
            Double ex=pt.first, ey=pt.second;
            int cnt = 0;
            rep(i,N){
                Double d = hypotl(ex-x[i], ey-y[i]);
                if (d <= r[i] + 1e-8) ++cnt;
            }
            if (cnt >= K){ ok = true; break; }
        }
        if (ok){
            hi = mi;
        } else {
            lo = mi;
        }
    }
    return hi;
}


int main() {
    cin >> N >> K;
    x.resize(N); x2.resize(N);
    y.resize(N); y2.resize(N);
    c.resize(N); c2.resize(N);
    rep(i,N){
        cin >> x[i] >> y[i] >> c[i];
        x2[i] = (Double)x[i] * x[i];
        y2[i] = (Double)y[i] * y[i];
        c2[i] = (Double)c[i] * c[i];
    }

    Double t = solve();
    printf("%.20Lf\n", t);
    return 0;
}


Measured memory_bytes: 1100