Test instructions
Give you n nodes of the tree, starting from 1 nodes, to each node has three cases, was killed back to 1 nodes, to find a hidden exit, along the adjacent edge of the current node to the next node, given the probability of three cases each node is Ki,ei,1-ki-ei, Expected to find the number of edges that have already been exported.
Analysis:
Use a tree-like DP to consider the problem. When a node is a leaf node it simply goes to the parent node, and the non-leaf node can go to the Father node and all child nodes.
EI represents the expectation that the I-node passes through the number of edges
Then leaf node: ei=ki*e1+ (1-ki-ei) * (e[par[i]]+1);//par[i] represents the Father node of I
Non-leaf node: ei=ki*e1+ (1-ki-ei) * (E[par[i]]/m+sum (e[son[i])/m+1)//m represents the number of edges connected to the I node, Son[i] represents the I node child
Next up is the processing ring.
Make ei=ai*e1+bi*e[par[i]]+ci;
HDU 4035Maze (tree + probability dp, Absolute Classic)