#include using namespace std; using ll = long long; using ld = long double; using ull = unsigned long long; template using max_heap = priority_queue; template using min_heap = priority_queue, greater>; #define rep(i, l, r) for (ll i = (l); i < (r); i++) #define rrep(i, r, l) for (ll i = (r); i-- > (l);) #define all(x) begin(x), end(x) template bool chmin(T& lhs, T rhs) { return lhs > rhs ? (lhs = rhs, true) : false; } template bool chmax(T& lhs, T rhs) { return lhs < rhs ? (lhs = rhs, true) : false; } struct IOIO { IOIO() { cin.tie(0)->sync_with_stdio(0); } } ioio; template ostream& operator<<(ostream& os, const pair& p) { os << '(' << p.first << ", " << p.second << ')'; return os; } template ostream& operator<<(ostream& os, const vector& vs) { os << '{'; rep(i, 0, (int)vs.size()) os << vs[i] << (i + 1 == (int)vs.size() ? "" : ", "); os << '}'; return os; } template ostream& operator<<(ostream& os, const set& vs) { os << '{'; for (auto it = vs.begin(); it != vs.end(); it++) { if (it != vs.begin()) { os << ", "; } os << *it; } os << '}'; return os; } template ostream& operator<<(ostream& os, const map& vs) { os << '{'; for (auto it = vs.begin(); it != vs.end(); it++) { if (it != vs.begin()) { os << ", "; } os << *it; } os << '}'; return os; } #ifdef DEBUG void dump_func() { cerr << endl; } template void dump_func(Head&& head, Tail&&... tail) { cerr << head; if (sizeof...(Tail) > 0) { cerr << ", "; } dump_func(std::move(tail)...); } #define dump(...) cerr << "[" + string(#__VA_ARGS__) + "] ", dump_func(__VA_ARGS__) #else #define dump(...) static_cast(0) #endif void solve() { int n, K; cin >> n >> K; vector> p(n + 1); rep(i, 0, n) { ll x, y; cin >> x >> y; p[i] = {x, y}; } vector dist(n + 1, vector(n + 1)); rep(i, 0, n + 1) rep(j, 0, n + 1) { dist[i][j] = hypot(p[i].first - p[j].first, p[i].second - p[j].second); } const ld none = 1e18; vector dp(1 << (n + 1), vector(n + 1, vector(K + 1, none))); dp[1 << n][n][K] = 0; rep(i, 0, 1 << (n + 1)) rep(j, 0, n + 1) rep(k, 0, K + 1) { if (dp[i][j][k] == none) continue; rep(l, 0, n + 1) { if (l == n) { chmin(dp[i][l][K], dp[i][j][k] + dist[j][l]); } else if (k > 0 && (i & (1 << l)) == 0) { chmin(dp[i | (1 << l)][l][k - 1], dp[i][j][k] + dist[j][l]); } } } cout << fixed << setprecision(10); cout << dp[(1 << (n + 1)) - 1][n][K] << '\n'; } int main() { int t = 1; while (t--) solve(); }