#include //#define int long long using namespace std; using LL = long long; using P = pair; using Tapris = tuple; #define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i) #define REP(i, n) FOR(i, 0, n) #define pb(a) push_back(a) #define all(x) (x).begin(),(x).end() const int INF = (int)1e9; const LL INFL = (LL)1e15; const int MOD = 1e9 + 7; int dy[]={0, 0, 1, -1, 0}; int dx[]={1, -1, 0, 0, 0}; /*************** using variables ***************/ int n, x[105], y[105]; double w[105]; double dp[1 << 15][15]; double weight[1 << 15]; /**********************************************/ bool contain(int mask, int pos){ return (mask & (1 << pos)) != 0; } signed main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> x[0] >> y[0] >> n; w[0] = 0.0; REP(i, n) cin >> x[i+1] >> y[i+1] >> w[i+1]; for(int mask = 0; mask < (1 << (n + 1)); ++mask){ double tmp = 0; for (int i = 0; i < n + 1; ++i){ if(!contain(mask, i)){ tmp += w[i]; } } weight[mask] = tmp; } REP(i, (1 << 13)) REP(j, 15) dp[i][j] = INF; dp[0][0] = 0; for(int mask = 0; mask < (1 << (n + 1)); mask++){ REP(i, n+1){ REP(p, n+1) if(!contain(mask, p)){ double cost = (abs(x[i] - x[p]) + abs(y[i] - y[p])) * (weight[mask] + 100.0) / 120.0; dp[mask | (1 << p)][p] = min(dp[mask | (1 << p)][p], dp[mask][i] + cost); } } } double totalw = 0; REP(i, n+1) totalw += w[i]; printf("%.9f\n" ,dp[(1 << (n+1)) - 1][0] + totalw); }