structedge { int to, nxt; db v; }e[maxn << 1]; int n, ptr, lnk[maxn]; db f[maxn], g[maxn], q[maxn];
inlinevoidadd(int bgn, int end, db val) { e[++ptr] = (edge){end, lnk[bgn], val}; lnk[bgn] = ptr; } inlineintrd() { registerint x = 0; char c = getchar(); while(!isdigit(c)) c = getchar(); while(isdigit(c)) x = x * 10 + (c ^ 48), c= getchar(); return x; } voiddfs(int x, int fa) { f[x] = 1.0; for(int p = lnk[x]; p; p = e[p].nxt) { int y = e[p].to; if(y == fa) continue; dfs(y, x); f[x] *= ((1.0 - e[p].v) * (1.0 - f[y]) + f[y]); } f[x] *= (1.0 - q[x]); } voidefs(int x, int fa, int ine) { if(!fa) { g[x] = f[x]; for(int p = lnk[x]; p; p = e[p].nxt) { int y = e[p].to; efs(y, x, p); } } else { db kx = ((1 - e[ine].v) * (1 - f[x]) + f[x]); g[x] = f[x] * ((g[fa] / kx) + (1 - g[fa]/kx) * (1 - e[ine].v)); for(int p = lnk[x]; p; p = e[p].nxt) { int y = e[p].to; if(y == fa) continue; efs(y, x, p); } } }
intmain() { n = rd(); for(int i = 1; i < n; ++i) { int u = rd(), v = rd(); db pi = rd(); pi *= 0.01; add(u, v, pi); add(v, u, pi); } for(int i = 1; i <= n; ++i) q[i] = rd(), q[i] *= 0.01; dfs(1, 0); efs(1, 0, 0); db sum = 0.0; for(int i = 1; i <= n; ++i) sum += (1 - g[i]); printf("%.6lf\n", sum); return0; }