#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int N = 60;
int n, k;
double x[N], y[N], c[N];

double dist(double x1, double y1, double x2, double y2){
    return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

double disti(int i, int j){
    return dist(x[i], y[i], x[j], y[j]);
}

int count(double px, double py, double t){
    int cnt = 0;
    REP(i,n){
        if (dist(x[i], y[i], px, py) * c[i] <= t + 1e-6){
            cnt++;
            // cout << i << " ";
        }
    }
    // cout << endl;
    return cnt;
}

class Point{
    public:
        double x, y;
        Point(double px, double py) {
            x = px;
            y = py;
        }
        Point sub(Point p2) {
            return Point(x - p2.x, y - p2.y);
        }
        Point add(Point p2) {
            return Point(x + p2.x, y + p2.y);
        }
        double distance(Point p2) {
            return sqrt((x - p2.x)*(x - p2.x) + (y - p2.y)*(y - p2.y));
        }
        Point normal() {
            double length = sqrt(x*x + y*y);
            return Point(x/length, y/length);
        }
        Point scale(double s) {
            return Point(x*s, y*s);
        }
};

class Circle {
    public:
        double x, y, r, left;
        Circle(double cx, double cy, double cr) {
            x = cx;
            y = cy;
            r = cr;
            left = x - r;
        }
        pair<Point, Point> intersections(Circle c) {
            Point P0(x, y);
            Point P1(c.x, c.y);
            double d, a, h;
            d = P0.distance(P1);
            a = (r*r - c.r*c.r + d*d)/(2*d);
            h = sqrt(r*r - a*a);
            Point P2 = P1.sub(P0).scale(a/d).add(P0);
            double x3, y3, x4, y4;
            x3 = P2.x + h*(P1.y - P0.y)/d;
            y3 = P2.y - h*(P1.x - P0.x)/d;
            x4 = P2.x - h*(P1.y - P0.y)/d;
            y4 = P2.y + h*(P1.x - P0.x)/d;

            return pair<Point, Point>(Point(x3, y3), Point(x4, y4));
        }
};

int main(void){
    cin >> n >> k;
    if (k == 1){
        cout << 0 << endl;
        return 0;
    }
    REP(i,n){
        cin >> x[i] >> y[i] >> c[i];
    }
    double ok = 2000000.0, ng = 0.0;
    REP(_,100){
        double t = (ok + ng) / 2.0;
        // t = 2.40001;
        // printf("%.15f\n", t);
        VD r(n);
        REP(i,n) r[i] = t / c[i];
        // REP(i,n) cout << r[i] << " ";
        // cout << endl;
        bool f = false;
        REP(i,n) REP(j,i){
            double d = disti(i, j);
            if (d > r[i] + r[j]) continue;
            if (d + r[j] < r[i]) continue;
            if (d + r[i] < r[j]) continue;
            // cout << i << " " << j << endl;
            Circle c1(x[i], y[i], r[i]), c2(x[j], y[j], r[j]);
            auto tmp = c1.intersections(c2);
            Point p1 = tmp.first, p2 = tmp.second;
            // printf("%.15f %.15f  %d\n", p1.x, p1.y, count(p1.x, p1.y, t));
            // printf("%.15f %.15f  %d\n", p2.x, p2.y, count(p2.x, p2.y, t));
            // cout << printf("%.15f\n", dist(x[0], y[0], p1.x, p1.y)) << endl;
            if (count(p1.x, p1.y, t) >= k || count(p2.x, p2.y, t) >= k){
                f = true;
            }
            if (f){
                i = n;
                break;
            }
        }
        REP(i,n) if (count(x[i], y[i], t) >= k) f = true;
        if (f) ok = t;
        else ng = t;
    }
    printf("%.15f\n", ok);
    return 0;
}


Measured memory_bytes: 256