#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-9;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
double dist(double a,double b,double c,double d){
    return pow(((a-c)*(a-c)+(b-d)*(b-d)),0.5);
}
pdd niji(double a,double b,double c){
    if(a==0)return {-c/b,-c/b};
    return {(-b+sqrt(b*b-4*a*c))/(2.0*a),(-b-sqrt(b*b-4*a*c))/(2.0*a)};
}
pdd ff(double a,double b,double c,double d,double e,double f){
    if(abs(b*d-a*e)<=eps)return {1000000000000,1000000000000};
    double rx=(c*e-b*f)/(b*d-a*e);
    double ry=(a*f-c*d)/(b*d-a*e);
    return {rx,ry};
}
pair<pdd,pdd> entotyoku(double x,double y,double r,double a,double b,double c){
    double aa=a*a+b*b;
    double bb=-2*x*b*b+2*a*c+2*a*b*y;
    double cc=b*b*x*x+(c+b*y)*(c+b*y)-b*b*r*r;
    pair<double,double> p=niji(aa,bb,cc);
    double x1=p.first,x2=p.second;
    if(x1==x2&&b==0){
        return {{x1,y+sqrt(r*r-(x1-x)*(x1-x))},{x1,y-sqrt(r*r-(x1-x)*(x1-x))}};
    }
    else{
        return {{x1,-a/b*x1-c/b},{x2,-a/b*x2-c/b}};
    }
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n,K;cin>>n>>K;
    double x[n],y[n];ll c[n];
    rep(i,0,n)cin>>x[i]>>y[i]>>c[i];
    double u=10000000,d=0;
    
    rep(i,0,128){
        double mid=(u+d)/2;
        //cout<<i<<" "<<mid<<endl;
        vector<pair<double,double>> v;
        double r[n];
        rep(j,0,n)r[j]=mid/c[j];
        rep(j,0,n-1){
            rep(k,j+1,n){
                double dd=dist(x[j],y[j],x[k],y[k]);
                if(dd>r[j]+r[k]+eps)continue;
                double a=2*(x[j]-x[k]),b=2*(y[j]-y[k]),c=-x[j]*x[j]+x[k]*x[k]-y[j]*y[j]
                +y[k]*y[k]-r[k]*r[k]+r[j]*r[j];
                
                pair<pdd,pdd> p=entotyoku(x[j],y[j],r[j],a,b,c);
                v.push_back(p.first);
                v.push_back(p.second);
            }
        }
        rep(j,0,n)v.push_back({x[j],y[j]});
        int rr=0;
        rep(j,0,v.size()){
            int cnt=0;
            rep(k,0,n){
                if(dist(v[j].first,v[j].second,x[k],y[k])<=r[k]+eps)cnt++;
            }
            if(cnt>=K){
                rr=1;
                break;
            }
        }
        if(rr){
            u=mid;
        }
        else d=mid;
       
    }
    cout<<fixed<<setprecision(12)<<u<<endl;
    
    
}







Measured memory_bytes: 384