#include<bits/stdc++.h> #define EPS 1e-8 #define MAX_N 500000 usingnamespace std; typedefdouble dnt; template <classT> inlinevoidread(T &x){ x = 0; int c = getchar(), f = 1; for (; !isdigit(c); c = getchar()) if (c == 45) f = -1; for (; isdigit(c); c = getchar()) (x *= 10) += f*(c-'0'); } int n; dnt f[MAX_N+5]; vector <int> G[MAX_N+5]; vector <dnt> E[MAX_N+5]; voidDFS(int u, int fa){ for (int i = 0; i < (int)G[u].size(); i++) { int v = G[u][i]; dnt w = E[u][i]; if (v ^ fa) DFS(v, u), f[u] *= 1-w*(1-f[v]); } } voidDFS(int u, int fa, dnt w){ if (fa && 1-w*(1-f[u]) >= EPS) f[u] *= 1-w*(1-f[fa]/(1-w*(1-f[u]))); for (int i = 0, v; i < (int)G[u].size(); i++) if ((v = G[u][i]) ^ fa) DFS(v, u, E[u][i]); } intmain(){ read(n); dnt ans = 0; for (int i = 1, u, v, c; i < n; i++) read(u), read(v), read(c), G[u].push_back(v), E[u].push_back(1.0*c/100), G[v].push_back(u), E[v].push_back(1.0*c/100); for (int i = 1, p; i <= n; i++) read(p), f[i] = 1-1.0*p/100; DFS(1, 0), DFS(1, 0, 0); for (int i = 1; i <= n; i++) ans += 1-f[i]; returnprintf("%.6lf\n", ans), 0; }