#include #include #include using namespace std; const int NUM = 14; const int BUF = 1 << NUM; const int INF = 1 << 30; int N; int x[NUM], y[NUM]; double w[NUM]; void read() { cin >> x[0] >> y[0]; w[0] = 0; cin >> N; for (int i = 1; i <= N; ++i) cin >> x[i] >> y[i] >> w[i]; ++N; } double calc(int s, int t, double totalW) { int dist = abs(x[s] - x[t]) + abs(y[s] - y[t]); return dist * (totalW + 100) / 120.0; } double rec(int pos, int mask, double dp[NUM][BUF]) { if (mask == (1 << N) - 1) return calc(pos, 0, 0); double &ret = dp[pos][mask]; if (ret > -0.5) return ret; ret = INF; double totalW = 0; for (int i = 0; i < N; ++i) if (!(mask & (1 << i))) totalW += w[i]; for (int i = 0; i < N; ++i) { if (mask & (1 << i)) continue; ret = min(ret, rec(i, mask | (1 << i), dp) + w[i] + calc(pos, i, totalW)); } return ret; } void work() { double dp[NUM][BUF]; for (int i = 0; i < NUM; ++i) for (int j = 0; j < BUF; ++j) dp[i][j] = -1; printf("%.10lf\n", rec(0, 0, dp)); } int main() { read(); work(); return 0; }