#include #define For(i, a, b) for(int i = a; i < b; i++) #define rep(i, n) For(i, 0, n) #define rFor(i, a, b) for(int i = a; i >= b; i--) #define ALL(v) (v).begin(), (v).end() #define rALL(v) (v).rbegin(), (v).rend() using namespace std; using lint = long long; using ld = long double; int INF = 2000000000; lint LINF = 1000000000000000000; struct Point { ld x, y; }; ld dist(Point a, Point b) { ld dx = a.x - b.x, dy = a.y - b.y; return sqrt(dx * dx + dy * dy); } int main() { int n, K; cin >> n >> K; n++; vector p(n); p[0] = {0.0, 0.0}; For(i, 1, n) { cin >> p[i].x >> p[i].y; } vector>> dp(1 << n, vector>(n, vector(K + 1, 1000000000000000000))); dp[1][0][K] = 0.0; rep(s, (1 << n)) { rFor(i, n - 1, 0) { rep(j, K + 1) { if (i == 0 && j != K) { continue; } rep(ni, n) { if (i == ni) { continue; } if (ni == 0) { ld d = dist(p[i], p[ni]); /*if (dp[s][0][K] > dp[s][i][j] + d) { cout << s << " " << i << " " << j << " -> " << s << " " << 0 << " " << K << endl; dp[s][0][K] = dp[s][i][j] + d; cout << dp[s][0][K] << endl; }*/ dp[s][0][K] = min(dp[s][0][K], dp[s][i][j] + d); } else { if (s & (1 << ni) || j == 0) { continue; } int ns = s | (1 << ni); ld d = dist(p[i], p[ni]); /* if (dp[ns][ni][j - 1] > dp[s][i][j] + d) { cout << s << " " << i << " " << j << " -> " << ns << " " << ni << " " << j - 1 << endl; dp[ns][ni][j - 1] = dp[s][i][j] + d; cout << dp[ns][ni][j - 1] << endl; }*/ dp[ns][ni][j - 1] = min(dp[ns][ni][j - 1], dp[s][i][j] + d); } } } } } /* rep(s, (1 << n)) rep(i, n) rep(j, K + 1) { if (dp[s][i][j] != 2000000000) { cout << s << " " << i << " " << j << " " << dp[s][i][j] << endl; } } */ ld ans = 1000000000000000000; rep(j, K + 1) { ans = min(ans, dp[(1 << n) - 1][0][j]); } cout << fixed << setprecision(10) << ans << endl; }