[Probability and expectation] HDU 4035

Source: Internet
Author: User

Channel: http://acm.hdu.edu.cn/showproblem.php? PID = 1, 4035

There are n rooms connected by N-1 tunnels. In fact, a tree is formed. Starting from node 1, there are three possibilities for each node I:

1. Killed, return to node 1 (probability is Ki)

2. Find the exit and exit the maze (probability is EI)
3. There are m edges connected to the vertex and a Random Edge is taken.
The expected value of the number of edges to walk out of the maze.

Ideas:

Set E [I] to represent the expected number of edges to walk out of the maze at node I. E [1] is the request. Leaf node: E [I] = Ki * E [1] + EI * 0 + (1-ei EI) * (E [Father [I] + 1 ); = Ki * E [1] + (1-0000ei) * E [Father [I] + (1-0000ei); Non-leaf node: (m is the number of edges connected to the node) E [I] = Ki * E [1] + EI * 0 + (1-ei EI) /M * (E [Father [I] + 1 + Σ (E [child [I] + 1); = Ki * E [1] + (1-127ei) /M * E [Father [I] + (1-0000ei)/m * Σ (E [child [I]) + (1-0000ei); set each node: E [I] = ai * E [1] + bi * E [Father [I] + ci; for non-leaf node I, set J to the child node of I, then Σ (E [child [I]) = Σ E [J] = Σ (AJ * E [1] + Bj * E [Father [J] + cj) = Σ (AJ * E [1] + Bj * E [I] + cj) Bring the formula above (1-(1-ei EI)/m * Σ BJ) * E [I] = (KI + (1-0000ei)/m * Σ AJ) * E [1] + (1-0000ei) /M * E [Father [I] + (1-0000ei) + (1-0000ei)/m * Σ CJ; thus, AI = (KI + (1-0000ei)/m * Σ AJ) can be obtained) /(1-(1-0000ei)/m * Σ BJ); Bi = (1-0000ei)/M/(1-(1-0000ei)/m * Σ BJ ); ci = (1-digit EI) + (1-digit EI)/m * Sigma CJ)/(1-(1-digit EI)/m * Sigma BJ); for leaf node AI = Ki; bi = 1-ki-EI; CI = 1-ki-EI; Starting from the leaf node until A1, B1, and c1 are calculated; E [1] = A1 * E [1] + B1 * 0 + C1; so E [1] = C1/(1-A1 ); if A1 approaches 1, there is no solution... (transferred from kuangbin)

Code:

Tag: Classic expectation DP

[Probability and expectation] HDU 4035

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.