#include #include #include #include #include #include #include #include #include using namespace std; typedef long long i64; typedef long double ld; typedef pair P; #define rep(i, s, e) for (int i = (s); i <= (e); i++) ld sx, sy; int n; ld x[13], y[13], w[13]; ld dp[(1 << 13)][20]; ld dist(ld x1, ld y1, ld x2, ld y2) { return abs(x1 - x2) + abs(y1 - y2); } int main() { cin >> sx >> sy; cin >> n; rep(i, 0, n - 1) cin >> x[i] >> y[i] >> w[i]; rep(i,0,(1 << 13) - 1) { rep(j,0,19) { dp[i][j] =1e9; } } ld w_sum = 0; rep(i, 0, n - 1) w_sum += w[i]; rep(i, 1, (1 << n) - 1) { if (__builtin_popcount(i) == 1) { rep(j, 0, n - 1) { if (i & (1 << j)) { dp[i][j] = dist(x[j], y[j], sx, sy) * (w_sum + 100) / 120 + w[j]; break; } } } else { rep(j, 0, n - 1) { if (i & (1 << j)) { ld weight = 0; int sub = i & ~(1 << j); rep(k, 0, n - 1) { if (!(sub & (1 << k))) { weight += w[k]; } } rep(k, 0, n - 1) { if ((sub & (1 << k))) { ld d = dist(x[j], y[j], x[k], y[k]); dp[i][j] = min(dp[i][j], dp[sub][k] + d * (weight + 100) / 120 + w[j]); } } } } } } cout << fixed << setprecision(10); ld result = 1e9; rep(i,0,n - 1) { ld d = dist(sx,sy,x[i],y[i]) * 100 / 120; result = min(result , dp[(1 << n) - 1][i] + d); } cout << result << endl; }