
ZOJ Problem Set  1273
A common component in electronic circuits is the resistor. Each resistor has two terminals, and when current flows through a resistor, some of it is converted to heat, thus ``resisting"; the flow of the current. The extent to which it does this is indicated by a single positive numeric value, cleverly called the resistance of the resistor. By the way, the units of resistance are Ohms. Here's what a single resistor looks like in a diagram of an electronic circuit: When two resistors are connected in series, as shown below, then their equivalent resistance is just the sum of the resistances of the individual resistors. For example, if the two resistors below had resistances of 100 and 200 Ohms, respectively, then the combined resistance (from point A to point B) would be 300 Ohms. Of course, combining three or more resistors in series would yield a resistance equal to sum of all the individual resistances. Resistors may also be connected in parallel, like this: If these two resistors had resistances of 100 and 150 Ohms, then the parallel combination would yield an equivalent resistance between points A and B of Connecting three resistors in parallel uses the same rule, so a 100 Ohm, 150 Ohm, and 300 Ohm resistor in parallel would yield a combined resistance of just 50 Ohms: that is, In this problem you're provided one or more descriptions of resistors and their interconnections. Each possible interconnection point (the terminals of a resistor) is identified by a unique positive integer, its label. And each resistor is specified by giving its two interconnection point labels and its resistance (as a real number). For example, the input 1 2 100 1 2 100 1 2 100 Notes 1. Be aware that there may be input test cases with some resistors that don't
contribute to the overall resistance between the indicated points. For example,
in the last case shown in the Sample Input section below, the resistor between
points 1 and 2 is unused. There must be some flow through a resistor if it is
to contribute to the overall resistance.
There will be one or more cases to consider. Each will begin with a line containing three integers N, A, and B. A and B indicate the labels of points between which you are to determine the equivalent resistance. N is the number of individual resistors, and will be no larger than 30. N, A and B will all be zero in the line following the last case. Following each ``N A B" line will be N lines, each specifying the labels of the points where a resistor is connected, and the resistance of that resistor, given as a real number.
2 1 3
Case 1: 300.00 Ohms Source: North Central North America 1996 