Description
Input Output Sample Input Sample Output HINT It is more difficult to solve the above problem directly by Source . This 23333 is more difficult to randomize well, since it is different or so bitwise contribution can then be dp[i] means that I to n the path of this one on the 1 probability of high chaos can be
#include <bits/stdc++.h> using namespace std;
const int MAXN = 110;
const int MAXM = 20020;
Const double EPS = 1e-9;
int n, m;
Double P[MAXN][MAXN], ANS[MAXN], ret;
inline void Gauss () {for (int i = 1; I <= n; i++) {int t = i;
for (int j = i + 1; j <= N; j + +) if (Fabs (p[j] [i]) > fabs (p[t [i] + eps)) t = j;
for (int j = i; J <= n + 1; j + +) swap (p[I [j], p[T] [j]);
for (int j = i + 1; j <= N; j + +) {Double t = p[j] [i]/p[I [i];
for (int k = i; k <= n + 1; k++) p[J [K]-= p[I [k] * t;
for (int i = n; i; i--) {Double cur = p[I] [n + 1];
for (int j = i + 1; j <= N; j + +) cur-= p[I [j] * ans[J];
ans[i] = cur/p[I [i]; } struct Edge {int to, NXT, Val;}
e[MAXM];
int HEAD[MAXN], CNT, D[MAXN]; inline void Addedge (int x, int y, int w) {e[++cnt].to = y; e[cnt].nxt = head[x]; head[x] = cnt; e[cnt].val = W ;
D[y]++; int main () {SCANF ("%d%d", &n, &m);
for (int i = 1; I <= m; i++) {int x, y, W;
scanf ("%d%d%d", &x, &y, &w);
Addedge (x, Y, W);
if (x ^ y) addedge (y, X, W);
for (int i = 0; I <= i++) {memset (ans, 0, sizeof (ans));
memset (p, 0, sizeof (p));
for (int x = 1; x <= n-1 x + +) {p[x] [x] =-1; for (int j = head[x]; j; j = e[J].nxt) {if (e[J].val >> i) & 1 p[x] [n + 1] = 1.0/d[
X], p[x] [e[j].to]-= 1.0/d[x];
else p[x] [e[j].to] + = 1.0/d[x];
} p[n [n] = 1;
Gauss ();
RET + + (1 << i) * ans[1];
return printf ("%.3lf\n", ret), 0; }