#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>

using namespace std;

constexpr long double EPS = 1e-8;

class Point{
    public: 
    long double x,y;
    int c = 0;
    Point(long double x = 0.0, long double y = 0.0): x(x), y(y) {}
    Point operator + (const Point &p) const { return Point(x+p.x, y+p.y); }
    Point operator - (const Point &p) const { return Point(x-p.x, y-p.y); }
    Point operator * (const long double &a) const { return Point(x*a, y*a); }
    Point operator / (const long double &a) const { return Point(x/a, y/a); }
    bool operator < (const Point &p) const { return (x != p.x ? x < p.x : y < p.y); }
    bool operator == (const Point &p) const { return fabsl(x - p.x) < EPS && fabsl(y - p.y) < EPS; }
    long double abs() const { return sqrt(norm()); }
    long double norm() const { return x*x + y*y; }
    long double dot(Point &p) const { return x*p.x + y*p.y; }
    long double cross(Point &p) const { return x*p.y - y*p.x; }   
};

class Circle{
    public:
    Point c;
    long double r;
    
    Circle(Point c = Point(), long double r = 0.0): c(c), r(r) {}
};

bool is_ok(int n, int k, vector<Point> &meats, double t) {
    // ある円の中心をすべて試す
    vector<Point> ps(meats);

    // 2つの円の交点をすべて試す
    // 参考: https://shogo82148.github.io/homepage/memo/geometry/circle-cross.html
    for(int i1=0;i1<n-1;++i1) {
        for(int i2=i1+1;i2<n;++i2) {
            Point p1 = meats[i1], p2 = meats[i2];
            Circle c1 = Circle(p1, t/p1.c), c2 = Circle(p2, t/p2.c);
            long double a = ((p2-p1).norm() + c1.r * c1.r - c2.r * c2.r) / 2.0;
            if((p2-p1).norm() * c1.r * c1.r - a * a < -EPS) continue;    // 交点なし
            a = max(0.0l, a);

            Point q = Point(
                (a * (p2.x - p1.x) + (p2.y - p1.y) * sqrt(max(0.0l, (p2-p1).norm() * c1.r * c1.r - a * a))) / (p2-p1).norm(), 
                (a * (p2.y - p1.y) - (p2.x - p1.x) * sqrt(max(0.0l, (p2-p1).norm() * c1.r * c1.r - a * a))) / (p2-p1).norm()
            ) + p1;
            ps.push_back(q);

            q = Point(
                (a * (p2.x - p1.x) - (p2.y - p1.y) * sqrt(max(0.0l, (p2-p1).norm() * c1.r * c1.r - a * a))) / (p2-p1).norm(), 
                (a * (p2.y - p1.y) + (p2.x - p1.x) * sqrt(max(0.0l, (p2-p1).norm() * c1.r * c1.r - a * a))) / (p2-p1).norm()
            ) + p1;
            ps.push_back(q);
        }
    }

    for(Point p: ps) {
        int k_cnt = 0;
        for(int j=0;j<n;++j) {
            if((meats[j] - p).norm()-EPS <= t / meats[j].c * t / meats[j].c) {
                ++k_cnt;
            }
        }
        if(k_cnt >= k) return true;
    }
    return false;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<Point> meats(n);
    for(int i=0;i<n;++i) {
        cin >> meats[i].x >> meats[i].y >> meats[i].c;
    }

    if(k == 1) {
        cout << 0 << endl;
        return 0;
    }

    double ng = 0.0, ok = 1e9; // その時間で K 枚以上の肉が焼けるか？
    for(int z=0;z<100;++z) {
        double t = (ok+ng) / 2.0;
        (is_ok(n, k, meats, t)?ok:ng) = t;
    }

    cout << fixed << setprecision(10) << ok << endl;

}


Measured memory_bytes: 584