#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
typedef pair<int,int> P;
int const inf=1e9+7;
using pd=pair<double,double>;

class Meet{
    public:
    double x,y,c;
    void input(){
        cin>>x>>y>>c;
    }
    double dist(double cx,double cy){
        return c*sqrt((x-cx)*(x-cx)+(y-cy)*(y-cy));
    }
};
bool compare(const Meet &a,const Meet &b){
    if(a.x==b.x){
        return a.y>b.y;
    }
    return a.x>b.x;
}

class F{
    public:
    double a,b;
    double rate;//cos
    bool virtical;
    pd center;
    void build(Meet x1,Meet x2){
        pd mid;
        pd r1;pd r2;
        r1={x1.x,x1.y};
        r2={x2.x,x2.y};
        mid.first=(r1.first*x1.c+r2.first*x2.c)/(x1.c+x2.c);
        mid.second=(r1.second*x1.c+r2.second*x2.c)/(x1.c+x2.c);
        center=mid;
        virtical=false;
        rate=1;
        if(r1.second==r2.second){
            virtical=true;
            a=inf;b=0;
            return;
        }
        a=(-1.0)*(r1.first-r2.first)/(r1.second-r2.second);
        b=mid.second-a*mid.first;
        rate=1.0/(sqrt(1+a*a));
    }
    pd out(double x){
        if(virtical){
            return {center.first,center.second+rate*x};
        }
        return {center.first+rate*x,center.second+rate*x*a};
    }
};

double calc(vector<Meet>const& niku,int k,double x,double y){
    int n=niku.size();
    vector<double> score(n);
    rep(i,n){
        double buf=(double)niku[i].c*sqrt(((double)niku[i].x-x)*((double)niku[i].x-x)+((double)niku[i].y-y)*((double)niku[i].y-y));
        score[i]=buf;
    }
    sort(score.begin(),score.end());
    return score[k-1];
}
void rotate(Meet& r,double theta){
    Meet hoge=r;
    hoge.x=r.x*sin(theta)+r.y*cos(theta);
    hoge.y=r.y*cos(theta)-r.x*sin(theta);
}
//////////////////////////////////

void calc2(Meet a,Meet b,vector<pair<double,double>>& res,double r){
    res.push_back({a.x,a.y});
    res.push_back({b.x,b.y});
    if(b.x==0){
        double y=1.0/(2.0*b.y)*(1.0/(a.c*a.c)-1.0/(b.c*b.c))*r*r+b.y/2.0;
        if(r*r/(a.c*a.c)-y*y<0)return;
        double x=sqrt(r*r/(a.c*a.c)-y*y);
        res.push_back({x,y});
        res.push_back({-x,y});
        return;
    }
    double A=(1.0/(a.c*a.c)-1.0/(b.c*b.c))*r*r+b.x*b.x+b.y*b.y;A/=2.0*b.x;
    double div=1.0+(b.y*b.y)/(b.x*b.x);
    double B=-2.0*A*b.y/(b.x*div);
    double C=(A*A-r*r/a.c/a.c)/div;
    if(B*B-4.0*C<0)return;
    if(B*B-4.0*C==0){
        double y=-B/2.0;
        double x=-b.y/b.x*y+A;
        res.push_back({x,y});
        return;
    }
    double y=(-B+sqrt(B*B-4.0*C))/2.0;
    double x=-b.y/b.x*y+A;
    res.push_back({x,y});
    y=(-B-sqrt(B*B-4.0*C))/2.0;
    x=-b.y/b.x*y+A;
    res.push_back({x,y});
}
bool judge(vector<Meet>& niku,double r,int k){
    int n=niku.size();
    bool res=false;
    for(int i=0;i<n;++i){
        for(int j=i+1;j<n;++j){
            pair<double,double> move={niku[i].x,niku[i].y};
            niku[i].x=0;niku[i].y=0;
            niku[j].x-=move.first;niku[j].y-=move.second;
            vector<pair<double,double>> pos;
            calc2(niku[i],niku[j],pos,r);
            niku[i].x=move.first;niku[i].y=move.second;
            niku[j].x+=move.first;niku[j].y+=move.second;
            for(auto& val:pos){
                val.first+=move.first;val.second+=move.second;
                int cnt=0;
                rep(x,n){
                    if((val.first-niku[x].x)*(val.first-niku[x].x)+(val.second-niku[x].y)*(val.second-niku[x].y)<=r*r/(niku[x].c*niku[x].c)+0.000005){
                        ++cnt;
                    }
                }
                if(cnt>=k){
                    //printf("x,y=%lf,%lf\n",val.first,val.second);
                    //printf("move(x, y)=%lf, %lf\n",move.first,move.second);
                    //printf("(i, j)=(%d, %d)\n",i,j);
                    return true;
                }
            }
        }
    }
    return res;
}
double solve(int n,int k,vector<Meet> niku){  
  double res=1e18;
  double down=0.0;double up=1e9;
  rep(h,200){
      double mid=(down+up)/2.0;
      if(judge(niku,mid,k)){
          up=mid;
      }
      else down=mid;
  }
  res=up;
  //printf("%.12lf\n",res);
  return res;
}
//////////////////////////////////

signed main(){
  int n,K;cin>>n>>K;
  vector<Meet> niku(n);
  rep(i,n){
      niku[i].input();
  }
  double res=1e18;
  if(K==1){
      cout<<0<<"\n";
      return 0;
  }
  rep(i,n){
      rep(j,n){
          if(i==j)continue;
          F f1;f1.build(niku[i],niku[j]);
          double buf=calc(niku,K,f1.center.first,f1.center.second);
          res=min(res,buf);
      }
  }
  rep(i,n){
      rep(j,n){
          if(i==j)continue;
          double buf=inf;
          double d=-2001;double u=2001;
          F f1;f1.build(niku[i],niku[j]);
          while(u-d>1e-8){
              double mid_d=(d+d+u)/3.0;
              double mid_u=(d+u+u)/3.0;
              double score_d=calc(niku,K,f1.out(mid_d).first,f1.out(mid_d).second);
              double score_u=calc(niku,K,f1.out(mid_u).first,f1.out(mid_u).second);
              if(score_d<niku[i].dist(f1.out(mid_d).first,f1.out(mid_d).second)){
                  score_d=inf;
              }
              if(score_u<niku[i].dist(f1.out(mid_u).first,f1.out(mid_u).second)){
                  score_u=inf;
              }
              if(score_d<score_u){
                  u=mid_u;
              }
              else d=mid_d;
              buf=score_d;
          }
          res=min(buf,res);
      }
  }
  res=min(res,solve(n,K,niku));
  printf("%.12lf\n",res);
  return 0;
}

Measured memory_bytes: 3804