spoj#RESIST. Kirchhof Law
Kirchhof Law
Input
Multiple test cases. For each test case:
The first line contains integers N and M; N is a number of nodes in the circuit (2 < N <= 100), M is the number of resistors (0 <= M <= 300). Each of the next M lines consists of three integers Ai, Bi and Ri — description of a resistor that has resistance Ri connecting the nodes Ai and Bi (1 <= Ai , Bi <= N; 1 <= Ri <= 100).
There's a blank line between consecutive test cases in the input file. No other extra whitespace will/should be appear in the input/output.
Input terminates by EOF.
Output
For each test case, output the total resistance between the nodes 1 and N rounded within two digits after a decimal points. There won't be any test case the output for which is +INF.
Example
Input: 4 5 1 2 15 2 4 5 1 3 10 3 4 10 2 3 1</p>Output: 9.40