#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
#include <cassert>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

int n, K;
vector<int> x, y, c;

const double eps = 1e-8;
bool chk(double x0, double y0, double m)
{
    int cnt = 0;
    int i;
    for (i = 0; i < n; i++) {
        double dx = x[i] - x0, dy = y[i] - y0;
        double tmp = sqrt(dx * dx + dy * dy);
        tmp *= c[i];
        if (tmp < m+eps) cnt++;
    }

    return (cnt >= K);
}


bool chk2(int id0, int id1, double m)
{
    double r0 = m / c[id0];
    double r1 = m / c[id1];
    double dx = x[id1] - x[id0], dy = y[id1] - y[id0];
    double L =  sqrt(dx * dx + dy * dy);

    double tmp0 = L*L + r0 * r0 - r1 * r1;
    double cc = tmp0 / (2 * L*r0);
    double ss = 1 - cc * cc;
    if (ss >= 0) {
        ss = sqrt(ss);
        
        {
            double dx2 = cc*dx - ss*dy;
            double dy2 = ss*dx + cc*dy;
            dx2 *= (r0 / L);
            dy2 *= (r0 / L);
            double x2 = x[id0] + dx2, y2 = y[id0] + dy2;
            bool ok = chk(x2, y2, m);
            if (ok) {
                return true;
            }
        }
        {
            ss = -ss;
            double dx2 = cc*dx - ss*dy;
            double dy2 = ss*dx + cc*dy;
            dx2 *= (r0 / L);
            dy2 *= (r0 / L);
            double x2 = x[id0] + dx2, y2 = y[id0] + dy2;
            bool ok = chk(x2, y2, m);
            if (ok) {
                return true;
            }
        }
    }

    return false;
}

void solve()
{
    scanf("%d%d", &n, &K);
 
    x.resize(n), y.resize(n), c.resize(n);
    int i, j;
    for (i = 0; i < n; i++) {
        scanf("%d%d%d", &x[i], &y[i], &c[i]);
    }

    double l = 0, r = 300000;
    int k;
    for(k=0; k<50; k++) {
        double m = (l + r) / 2;

        bool ok = false;
        for (i = 0; i < n; i++) {
            ok = chk(x[i], y[i], m);
            if (ok) {
                break;
            }
        }

        if (!ok) {
            for (i = 0; i < n; i++) {
                for (j = i + 1; j < n; j++) {
                    ok = chk2(i, j, m);
                    if (ok) {
                        break;
                    }
                }
                if (ok) {
                    break;
                }
            }
        }

        if (ok) {
            r = m;
        }
        else {
            l = m;
        }
    }
    printf("%.10lf\n", r);

    return;
}

int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}



Measured memory_bytes: 256