#P2011. 计算电压
计算电压
Description
You are given a resistor network. The resistance on each edge is known, and the voltages between several nodes and the negative terminal are given (the power-supply voltage is constant). Now compute the voltage between any two nodes.
Input Format
The first line contains four positive integers , indicating there are nodes (some nodes may be connected by wires and thus are equivalent to one node; nodes are numbered to , and node is the negative terminal of the power supply), fixed resistors (each fixed resistor connects two nodes), the positive terminal of the power supply has terminals, and there are queries.
The next lines each contain two positive integers, indicating the index of this positive terminal and the voltage between this binding post and the negative terminal.
The next lines each contain three positive integers , indicating that there is a resistor of resistance between nodes and .
The next lines each contain two positive integers , indicating that you need to compute the voltage between and .
Output Format
Output lines. Each line contains one real number representing the voltage between and (rounded to two decimal places). If the voltage at is less than the voltage at , output a negative value.
3 5 1 3
1 18
1 2 6
1 3 2
2 3 6
3 0 6
2 0 2
1 0
2 3
1 2
18.00
-6.00
12.00
Hint
Constraints
- For of the testdata, .
- For of the testdata, , and the circuit is guaranteed to be series, parallel, or a mixed connection.
- For of the testdata, , .
- For of the testdata, , , , .
Time and Memory Limits
Time limit: 1.00 s, Memory limit: 125.00 MB.
Sample Explanation
As shown in the figure.

Translated by ChatGPT 5
京公网安备 11011102002149号