#include #include #include #include #include #include #include using namespace std; typedef pair P; typedef long long ll; #define For(i, a, b) for(int i = (a); i < (b); i++) #define Rep(i, n) For(i, 0, (n)) const double inf = 1e15; const int mod = 1000000007; double dp[1 << 15][20]; int x[20], y[20]; double w[20]; double all_w; int dis[20][20]; int main(){ int a, b; cin >> a >> b; int n; cin >> n; x[0] = a; y[0] = b; For(i, 1, n + 1){ cin >> x[i] >> y[i] >> w[i]; all_w += w[i]; } n += 1; Rep(i, 1 << n) Rep(j, n) dp[i][j] = inf; dp[0][0] = 0; Rep(i, 1 << n) Rep(j, n) if(dp[i][j] < inf){ double now_w = all_w; Rep(k, n) if(i & 1 << k) now_w -= w[k]; Rep(k, n) if(!(i & 1 << k)){ double dis = abs(x[j] - x[k]) + abs(y[j] - y[k]); double add_dis = dis * (now_w + 100.0) / 120; dp[i | 1 << k][k] = min(dp[i | 1 << k][k], dp[i][j] + add_dis + w[k]); } } cout << dp[(1 << n) - 1][0] << endl; return 0; }