#P4284. [SHOI2014] 概率充电器
[SHOI2014] 概率充电器
Description
The famous electronics brand SHOI has just released the next-generation product leading the global trend — the Probability Charger:
“Using brand-new nano-scale fabrication technology, whether components and wires conduct is determined entirely by true random numbers! The SHOI Probability Charger, an indispensable necessity in your life! Can it charge? Try it now!”
The SHOI Probability Charger connects charging components with wires. During charging, whether each wire can conduct is decided by probability, and whether each component charges directly is also decided by probability. Then electric energy can travel from components that charge directly, through conducting wires, to make other components charge indirectly.
As a loyal customer of SHOI, you cannot resist the impulse to buy SHOI products. After waiting in a long line for a week, you finally get the latest model of the SHOI Probability Charger. You eagerly plug it into the power source — and suddenly wonder: what is the expected number of components that enter the charging state?
Input Format
The first line contains an integer , the number of charging components. The components are numbered .
Each of the next lines contains three integers , describing a wire connecting components and , with conduction probability .
The -th line contains integers , meaning that component charges directly with probability .
Output Format
Output one real number: the expected number of components that enter the charging state, rounded to 6 decimal places.
3
1 2 50
1 3 50
50 0 0
1.000000
5
1 2 90
1 3 80
1 4 70
1 5 60
100 10 20 30 40
4.300000
Hint
- Constraints:
- For of the testdata, .
- For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号