#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; #define __float128 double #define MAX 22 __float128 dp[MAX]; vector > v[MAX]; int deg[MAX]; vector > pp[MAX]; int n; int m; queue q; struct st { int a, b; double p; st() { scanf("%d%d", &a, &b); int c; cin>>c; p=c; //scanf("%lf", &p); p /= 100.0; } }; vector vv; bool use[MAX]; inline void dfs(int b) { deg[b]--; if (deg[b] < 0 && b != 0) { exit(1); } if (deg[b] <= 0) { const int k = 1 << (pp[b].size()); for (int i = 1;i < k;i++) { __float128 sum = 1.0; bool flag = false; for (int j = 0;j < pp[b].size();j++) { if ((i >> j) & 1) { sum *= dp[pp[b][j].first] *(__float128)( pp[b][j].second); flag ^= true; } } if (flag) { dp[b] += sum; } else { dp[b] -= sum; } } for (int i = 0;i < v[b].size();i++) { dfs(v[b][i].first); } } } int main() { cin >> n >> m; for (int i = 0;i < m;i++) { vv.push_back(st()); v[vv.back().a].push_back(make_pair(vv.back().b, vv.back().p)); } use[0] = true; q.push(0); while (!q.empty()) { int b = q.front(); q.pop(); for (int i = 0;i < v[b].size();i++) { if (use[v[b][i].first]) { continue; } q.push(v[b][i].first); use[v[b][i].first] = true; } } for (int i = 0;i < n;i++) { v[i].clear(); } for (int i = 0;i < m;i++) { if (use[vv[i].a] && use[vv[i].b]) { v[vv[i].a].push_back(make_pair(vv[i].b, vv[i].p)); deg[vv[i].b]++; pp[vv[i].b].push_back(make_pair(vv[i].a,vv[i].p)); } } dp[0] = 1.0; dfs(0); double ans = dp[n - 1]; printf("%.16f\n", ans); return 0; }