#include #include using namespace std; const int N = 15; double dp[N][1 << N]; double x[N], y[N], w[N]; const double INF = 1e18; int n; double dist(int i, int j){ return abs(x[i] - x[j]) + abs(y[i] - y[j]); } double calc(int i, int j, int w){ return dist(i, j) * (w + 100) / 120; } double rec(int v, int vis){ if (!v && vis) return vis + 1 == 1 << n ? 0 : INF; double &res = dp[v][vis]; if (res >= -.5) return res; double wt = 0; for (int i = 0; i < n; ++i) if (~vis >> i & 1) wt += w[i]; res = INF; for (int i = 0; i < n; ++i){ if (vis >> i & 1) continue; res = min(res, rec(i, vis | (1 << i)) + calc(v, i, wt) + w[i]); } return res; } int main(){ cout.setf(ios::fixed); cout.precision(100); cin >> x[0] >> y[0] >> n; ++n; for (int i = 1; i < n; ++i) cin >> x[i] >> y[i] >> w[i]; for (int i = 0; i < 1 << N; ++i) for (int j = 0; j < N; ++j) dp[j][i] = -1; cout << rec(0, 0) << endl; }