using namespace std; #include #include #include #include #include #include #include typedef long long ll; ll INF = LLONG_MAX / 2; int main() { int N, M; cin >> N >> M; vector A(M), B(M), C(M); vector c(M); for (int i = 0; i < M; i++) { cin >> A[i] >> B[i] >> C[i]; c[i] = C[i] / 100.0; } double sum = 0; for (int S = 0; S < 1<<(N - 2); S++) { vector a(N); a[0] = a[N - 1] = true; for (int u = 0; u < N - 2; u++) a[u + 1] = S>>u & 1; vector p(N, 1), q(N, 1); for (int i = 0; i < M; i++) if (a[A[i]]) { p[B[i]] *= c[i]; q[B[i]] *= 1 - c[i]; } double x = 1; for (int u = 1; u < N; u++) x *= 1 - (a[u] ? q[u] : p[u]); sum += x; } printf("%.10f\n", sum); }