#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef string S;

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
#define int long long

const int N = 500000;
const int MOD = 998244353;
const double eps = 1e-8;

int n, K;
int x[N], y[N];
double c[N];
int print_mode = 0;

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

int ch(int i, double x0, double y0, double t)
{
    if (dist(x0, y0, x[i], y[i]) * c[i] <= t + eps) return 1;
    return 0;
}

int calc(double x0, double y0, double t)
{
    int cnt = 0;
    for (int i = 0; i < n; i++) cnt += ch(i, x0, y0, t);
    if (cnt >= K)
    {
        //printf("%.9f, %.9f\n", x0, y0);
        //for (int i = 0; i < n; i++) printf("%.9f\n", dist(x0, y0, x[i], y[i]));
    }
    return cnt;
}

int cx[4] = {1, -1, -1, 1};
int cy[4] = {1, 1, -1, -1};

int check(double t)
{
    for (int i = 0; i < n; i++)
    {
        if (calc(x[i], y[i], t) >= K) return 1;
    }
    //printf("%.9f\n", t);
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            double r1 = t / c[i];
            double r2 = t / c[j];
            double d = dist(x[i], y[i], x[j], y[j]);
            double d1 = (r1 * r1 - r2 * r2 + d * d) / (2 * d);
            double d2 = (r2 * r2 - r1 * r1 + d * d) / (2 * d);
            if (r1 * r1 >= d1 * d1 && r2 * r2 >= d2 * d2)
            {
                double xx = x[i] * (d2 / d) + x[j] * (d1 / d);
                double yy = y[i] * (d2 / d) + y[j] * (d1 / d);
                double h = sqrt(r1 * r1 - d1 * d1);
                double yprop = abs(y[i] - y[j]) / d;
                double xprop = abs(x[i] - x[j]) / d;
                double a = h * xprop;
                double b = h * yprop;
                //printf("www %.9f %.9f %.9f %.9f %.9f %.9f\n", xx, yy, t, h, a, b);
                int cn = 0;
                for (int k = 0; k < 4; k++)
                {
                    double nx = xx + cx[k] * b, ny = yy + cy[k] * a;
                    if (calc(nx, ny, t) >= K) return 1;
                    double dd1 = dist(nx, ny, x[i], y[i]);
                    double dd2 = dist(nx, ny, x[j], y[j]);
                    if (abs(dd1 - r1) <= eps && abs(dd2 - r2) <= eps) cn++;
                }
                if (cn < 2)
                {
                    cout << i << " " << j << endl;
                    printf("%.9f", t);
                    exit(10);
                }
            }
        }
    }
    return 0;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> K;
    for (int i = 0; i < n; i++) cin >> x[i] >> y[i] >> c[i];
    double L = 0, R = 1e12;
    for (int it = 0; it < 77; it++)
    {
        double mid = (L + R) / 2;
        if (check(mid)) R = mid;
        else L = mid;
    }
    printf("%.9f", R);
}


Measured memory_bytes: 4352