#include #include #include #include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = uint32_t; using namespace std; template constexpr T INF = ::numeric_limits::max() / 32 * 15 + 208; template vector make_v(U size, const T& init){ return vector(static_cast(size), init); } template auto make_v(U size, Ts... rest) { return vector(static_cast(size), make_v(rest...)); } template void chmin(T &a, const T &b){ a = (a < b ? a : b); } template void chmax(T &a, const T &b){ a = (a > b ? a : b); } int main() { int x, y, n; cin >> x >> y >> n; vector xs(n), ys(n); vector ws(n); for (int i = 0; i < n; ++i) { cin >> xs[i] >> ys[i] >> ws[i]; } auto dp = make_v(n, 1 << n, INF); vector ww(1<= 0; --i) { for (int k = 0; k < n; ++k) { if(not (i & (1 << k))) { for (int j = 0; j < n; ++j) { if(k != j && not (i & (1 << j))){ int from = i ^ (1 << j); dp[j][i] = min(dp[j][i], dp[k][from] + ws[j]+ (100+ww[from])/120.0*(abs(xs[k]-xs[j])+abs(ys[k]-ys[j]))); } } } } } double ans = INF; for (int i = 0; i < n; ++i) { ans = min(ans, dp[i].front()+(abs(xs[i]-x)+abs(ys[i]-y))/1.2); } printf("%.10lf\n", ans); return 0; }