#include using namespace std; template bool cmin(T &a, U b) { return a > b && (a = b, true); } template bool cmax(T &a, U b) { return a < b && (a = b, true); } signed main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int X, Y, N; cin >> X >> Y >> N, N++; vector> V(N); V.at(0) = {X, Y, 0}; for (int i = 1; i < N; i++) { int x, y; double w; cin >> x >> y >> w; V.at(i) = {x, y, w}; } vector> dist(N, vector(N)); for (int i = 0; i < N; i++) { for (int j = 0; j < N; j++) { auto [a, b, c] = V.at(i); auto [d, e, f] = V.at(j); dist.at(i).at(j) = abs(a - d) + abs(b - e); } } vector weight(1 << N); for (int bit = 0; bit < 1 << N; bit++) { double tmp = 0; for (int i = 0; i < N; i++) { if (bit >> i & 1) { auto [a, b, c] = V.at(i); tmp += c; } } weight.at(bit) = tmp; } vector> DP(1 << N, vector(N, DBL_MAX)); DP.at(1).at(0) = 0; for (int bit = 0; bit < 1 << N; bit++) { for (int from = 0; from < N; from++) { if (DP.at(bit).at(from) == DBL_MAX) continue; for (int to = 0; to < N; to++) { double cost = dist.at(from).at(to) * ((weight.at(bit) + 100) / 120); cmin(DP.at(bit | 1 << to).at(to), DP.at(bit).at(from) + cost); } } } double ans = DP.at((1 << N) - 1).at(0); for (auto [a, b, c] : V) ans += c; cout << fixed << setprecision(7) << ans << "\n"; }