#include using namespace std; void chmin(double &x, double y) { if(x > y) x = y; } int main() { int N, K; cin >> N >> K; vector x(N), y(N); for(int i = 0; i < N; i++) { cin >> x[i] >> y[i]; } vector dp(1 << N, vector(N + 1, vector(K + 1, INFINITY))); dp[0][N][K] = 0; for(int s = 0; s < 1 << N; s++) { // house to shop for(int i = 0; i < N; i++) { for(int k = 0; k < K; k++) { chmin(dp[s][N][K], dp[s][i][k] + hypot(x[i], y[i])); } } // shop to house for(int j = 0; j < N; j++) { chmin(dp[s | (1 << j)][j][K - 1], dp[s][N][K] + hypot(x[j], y[j])); } // house to house for(int i = 0; i < N; i++) { for(int j = 0; j < N; j++) { for(int k = 1; k <= K; k++) { chmin(dp[s | (1 << j)][j][k - 1], dp[s][i][k] + hypot(x[i] - x[j], y[i] - y[j])); } } } } cout << fixed << setprecision(10) << dp[(1 << N) - 1][N][K] << endl; }