#include #include #include #include using namespace std; int main() { int n, c; cin >> n >> c; ++n; vector x(n), y(n); for (int i = 1; i < n; ++i) cin >> x[i] >> y[i]; vector>> dp(1 << n, vector> (n, vector (c + 1, 1e300))); dp[1][0][c] = 0; for (int i = 0; i < 1 << n; ++i) { for (int k = 0; k <= c; ++k) dp[i][0][c] = min(dp[i][0][k], dp[i][0][c]); for (int j = 0; j < n; ++j) { if (!(i & (1 << j))) continue; for (int k = c; k > 0; --k) { for (int l = 0; l < n; ++l) { int id = (i | (1 << l)); dp[id][l][k - 1] = min(dp[id][l][k - 1], dp[i][j][k] + hypot(x[l] - x[j], y[l] - y[j])); } } for (int k = 0; k <= c; ++k) dp[i | 1][0][c] = min(dp[i | 1][j][k] + hypot(x[j] - x[0], y[j] - y[0]), dp[i | 1][0][c]); } } double ans = dp[(1 << n) -1][0][c]; printf("%.10f\n", ans); }