#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

namespace geo{
    struct RN{
        constexpr static double eps{1e-9};
        double x;
        constexpr RN(double x=0):x(x){}
        bool operator<(const RN a)const{return eps<a.x-x;}
        bool operator>(const RN a)const{return eps<x-a.x;}
        bool operator<=(const RN a)const{return -eps<a.x-x;}
        bool operator>=(const RN a)const{return -eps<x-a.x;}
        bool operator==(const RN a)const{return -eps<a.x-x&&a.x-x<eps;}
        bool operator!=(const RN a)const{return a.x-x<-eps||eps<a.x-x;}
        RN operator+(const RN a)const{return RN{x+a.x};}
        RN operator-(const RN a)const{return RN{x-a.x};}
        RN operator*(const RN a)const{return RN{x*a.x};}
        RN operator/(const RN a)const{return RN{x/a.x};}
        RN& operator+=(const RN a){x+=a.x;return *this;}
        RN& operator-=(const RN a){this->x-=a.x;return *this;}
        RN& operator*=(const RN a){this->x*=a.x;return *this;}
        RN& operator/=(const RN a){this->x/=a.x;return *this;}
    };
    istream& operator>>(istream &in,RN& x){
        double x_;
        in>>x_;
        x=RN{x_};
        return in;
    }
    ostream& operator<<(ostream &out,const RN& x){
        return out<<x.x;
    }

    constexpr RN pi{3.1415926535897932384626};
    using T=RN;

    struct Point{
        T x,y;
        explicit Point(T x=0,T y=0):x(x),y(y){}
        Point operator+(const Point& a)const{return Point(x+a.x,y+a.y);}
        Point operator-(const Point& a)const{return Point(x-a.x,y-a.y);}
        Point&operator+=(const Point& a){x+=a.x;y+=a.y;return *this;}
        Point&operator-=(const Point& a){x-=a.x;y-=a.y;return *this;}
        Point operator*(const T&c)const{ return Point(x*c,y*c);}
        Point operator/(const T&c)const{ return Point(x/c,y/c);}
        T operator*(const Point& a)const{return x*a.x+y*a.y;}
        T operator^(const Point& a)const{return x*a.y-y*a.x;}
        bool operator<(const Point& a)const{
            if(y==0&&x<0) return !(a.y==0&&a.x<0);
            if(a.y==0&&a.x<0) return false;
            if(y>=0){
                if(a.y<0) return false;
                return (*this^a)>0;
            }
            else{
                if(a.y>=0) return true;
                return (*this^a)>0;
            }
        }
        Point rot(double theta)const{
            T c{cos(theta)},s(sin(theta));
            return Point(x*c-y*s,x*s+y*c);
        }
        T norm()const{
            return x*x+y*y;
        }
        T dis(){
            return sqrt(norm().x);
        }
        T arg(){
            return atan2(y.x,x.x);
        }
    };
    istream& operator>>(istream &in,Point& a){
        return in>>a.x>>a.y;
    }
    ostream& operator<<(ostream &out,const Point& a){
        return out<<"("<<a.x<<","<<a.y<<")";
    }
    T dis(const Point&a,const Point&b){return (a-b).dis();}

    short ccw(const Point&a,Point b,Point c){
        b-=a;c-=a;
        if((b^c)>0) return 1;
        if((b^c)<0) return -1;
        if((b*c)<0) return 2;
        if(b.norm()<c.norm()) return -2;
        return 0;
    }

    struct Line{
        Point a,b;
        Line():a(),b(){}
        Line(Point a,Point b):a(a),b(b){}
        Line(T x, T y,T X,T Y):a(x,y),b(X,Y){}
        Line(T A,T B,T C){
            if(A==0) a=Point(0,C/B),b=Point(1,C/B);
            else if(B==0) a=Point(C/A,0),b=Point(C/A,1);
            else a=Point(0,C/B),b=Point(C/A,0);
        }
    };
    istream& operator>>(istream &in,Line& a){
        return in>>a.a>>a.b;
    }
    ostream& operator<<(ostream &out,const Line& a){
        return out<<a.a<<" to "<<a.b;
    }
    bool para(const Line&a,const Line&b){return ((a.b-a.a)^(b.b-b.a))==0;}
    bool orth(const Line&a,const Line&b){return ((a.b-a.a)*(b.b-b.a))==0;}

    Point proj(const Line&l,const Point&p){
        T t=(p-l.a)*(l.a-l.b)/(l.a-l.b).norm();
        return l.a+(l.a-l.b)*t;
    }

    Point ref(const Line&l,const Point&p){
        return p+(proj(l,p)-p)*2.0;
    }

    T dis(const Line&l,const Point&p){
        return dis(p,proj(l,p));
    }

    T dis(const Point&p,const Line&l){
        return dis(l,p);
    }

    Point cross(const Line&x,const Line&y){
        T a=(x.b-x.a)^(y.b-y.a);
        T b=(x.b-x.a)^(x.b-y.a);
        if(a==0&&b==0) return y.a;
        return y.a+(y.b-y.a)*(b/a);
    }

    short sgn(T x){
        if(x>0) return 1;
        if(x<0) return -1;
        return 0;
    }

    bool iscross(const Line&x,const Line&y){
        T asx=x.a.x,asy=x.a.y,atx=x.b.x,aty=x.b.y;
        T bsx=y.a.x,bsy=y.a.y,btx=y.b.x,bty=y.b.y;
        return sgn((asx-bsx)*(bsy-bty)+(asy-bsy)*(btx-bsx))*sgn((atx-bsx)*(bsy-bty)+(aty-bsy)*(btx-bsx))<=0
               &&sgn((bsx-asx)*(asy-aty)+(bsy-asy)*(atx-asx))*sgn((btx-asx)*(asy-aty)+(bty-asy)*(atx-asx))<=0;
        //strict-> ==-1
    }

    struct Circle{
        Point p;
        RN r;
        Circle()= default;
        Circle(Point p,RN r):p(p),r(r){}
        Circle(RN a,RN b,RN r):p(a,b),r(r){}
    };

    ostream& operator<<(ostream &out,const Circle& c){
        return out<<"("<<c.p<<","<<c.r<<")";
    }

    pair<Point,Point> cross(const Circle&c1,const Circle&c2){
        T d=dis(c1.p,c2.p);
        T a=acos(((c1.r*c1.r+d*d-c2.r*c2.r)/(c1.r*d*2)).x);
        T t=atan2((c2.p.y-c1.p.y).x,(c2.p.x-c1.p.x).x);
        Point p1=c1.p+Point(cos((t+a).x),sin((t+a).x))*c1.r;
        Point p2=c1.p+Point(cos((t-a).x),sin((t-a).x))*c1.r;
        return {p1,p2};
    }

    pair<Point,Point> cross(const Circle&c,const Line&l){
        Point p=proj(l,c.p);
        Point e=(l.b-l.a)/dis(l.a,l.b);
        if(dis(l,c.p)==c.r) return {p,p};
        double b=sqrt((c.r*c.r-(p-c.p).norm()).x);
        return {p-e*b,p+e*b};
    }

    vector<Point> convex_hull(vector<Point>&vp){
        int n=vp.size(),k{};
        if(n<=2) return vp;
        sort(vp.begin(),vp.end(),[](const Point&a,const Point&b){
            return a.x==b.x?a.y<b.y:a.x<b.x;
        });
        vector<Point> ch(2*n);
        for(int i=0;i<n;ch[k++]=vp[i++]){
            while(k>=2&&((ch[k-1]-ch[k-2])^(vp[i]-ch[k-1]))<=0) --k;
        }
        for(int i=n-2,t=k+1;i>=0;ch[k++]=vp[i--]){
            while(k>=t&&((ch[k-1]-ch[k-2])^(vp[i]-ch[k-1]))<=0) --k;
        }
        ch.resize(k-1);
        return ch;
    }
}
using namespace geo;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    istream& in(cin);
    ostream& out(cout);
    int n,k,x,y;
    in>>n>>k;
    vector<Point> ps(n);
    vector<int> c(n);
    fr(i,n){
        in>>x>>y>>c[i];
        ps[i]=Point(x,y);
    }
    double l=0,r=1e6,m;
    fr(_,50){
        m=(l+r)/2;
        vector<Circle> v(n);
        vector<Point> t;
        fr(i,n) v[i]=Circle(ps[i],m/c[i]);
        fr(i,n){
            t.push_back(ps[i]);
            fr(j,i){
                auto cs=cross(v[i],v[j]);
                if(!std::isnan(cs.first.x.x)){
                    if(abs(cs.first.x.x)<1000.1&&abs(cs.first.y.x)<1000.1)t.push_back(cs.first);
                    if(abs(cs.second.x.x)<1000.1&&abs(cs.second.y.x)<1000.1)t.push_back(cs.second);
                }
            }
        }
        bool F{};
        int tmp{};
        for(auto p:t){
            tmp=0;
            fr(i,n) if(dis(p,ps[i])<=v[i].r) ++tmp;
            if(tmp>=k){
                F=true;
                break;
            }
        }
        if(F) r=m;
        else l=m;
    }
    cout<<setprecision(20)<<r<<endl;
}


Measured memory_bytes: 384