#include "bits/stdc++.h" using namespace std; #define rt return #define FOR(i,j,k) for(int i=j; i<(int)k;++i) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define mt make_tuple #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef double Weight; struct Edge{ int from, to; Weight wei; Edge(int from_, int to_, Weight wei_):from(from_),to(to_),wei(wei_){} }; typedef vector Edges; typedef vector Graph; class TopologicalSort{ public: vi operator()(const Graph &G){ vis = vi((int)G.size()); hasCycle = 0; rep(i, G.size()){ dfs(G, i); if(hasCycle) return vi(); } reverse(all(res)); return move(res); } private: vi vis, res; bool hasCycle; void dfs(const Graph &G, int v){ if(vis[v] == 1) hasCycle = 1; if(vis[v]) return; vis[v] = 1; for(const Edge &edge: G[v]) dfs(G, edge.to); vis[v] = 2; res.push_back(v); } }; Graph makeWDGraph(int V, const vector &from, const vector &to, const vector &wei){ Graph G(V); int E = (int)from.size(); for(int i=0;i> N >> M; vi A(M), B(M); vector C(M); rep(i, M){ cin >> A[i] >> B[i] >> C[i]; C[i] *= 0.01; } Graph G = makeWDGraph(N, A, B, C); vi vers = TopologicalSort()(G); p[0] = 1; each(v, vers){ each(e, G[v]){ p[e.to] += (1 - p[e.to])*e.wei*p[v]; } } printf("%0.20f\n", p[N - 1]); }