int n; structnode { int to, next; double w; } g[maxn];
int ecnt = 2, head[maxn];
double f__[maxn]; double q[maxn];
voidadd_edge(int u, int v, double w){ g[ecnt] = (node) {v, head[u], w}; head[u] = ecnt ++; }
voiddfs_1(int u, int p){ f__[u] = 1.0 - q[u]; for (int e = head[u]; e != 0; e = g[e].next) { int v = g[e].to; if (v == p) continue; dfs_1(v, u); f__[u] *= f__[v] + (1 - f__[v]) * (1 - g[e].w); } }
voiddfs_2(int u, int p){ for (int e = head[u]; e != 0; e = g[e].next) { int v = g[e].to; if (v == p) continue; double t = f__[u] / (f__[v] + (1 - f__[v]) * (1 - g[e].w)); f__[v] *= (t + (1 - t) * (1 - g[e].w)); dfs_2(v, u); } }
intmain(){ cin >> n; for (int i = 1; i < n; i ++) { int u, v, w; cin >> u >> v >> w; add_edge(u, v, ((double) w) * 0.01); add_edge(v, u, ((double) w) * 0.01); } for (int i = 1; i <= n; i ++) cin >> q[i], q[i] *= 0.01; dfs_1(1, 0); dfs_2(1, 0); double ans = 0; for (int i = 1; i <= n; i ++) ans += 1 - f__[i]; printf("%.6lf\n", ans); return0; }