Kirchhoff's Laws
Time limit2sMemory limit512 MB
Given a resistor network, compute the equivalent resistance between node 1 and node N by solving Kirchhoff's laws.
- Level
Hard8 of 10
- Topics
- Graph, Math, Matrix, Implementation
- Solved
- No attempts yet
Problem
A circuit has nodes and resistors. A resistor joins two different nodes, and two nodes can be joined by more than one resistor.
Push a current of 1 A into node 1 and draw the same current out of node . The potential difference between the two nodes is the total resistance between node 1 and node . Read the circuit and compute that total resistance.
Input
The first line has the number of nodes and the number of resistors . (, )
Each of the next lines describes one resistor as three integers , , , meaning a resistor of value joins node and node . (, , )
Not every node is guaranteed to be connected to node 1. The total resistance between node 1 and node is never infinite.
Output
Print the total resistance between node 1 and node , rounded at the third decimal place and written with exactly two decimals. When the exact value sits halfway between two candidates, round up. For an exact value of 79.595, print 79.60.