Gears are useful, but can be so confusing! Your boss at Geartopia, Inc. wants you to write a program to help cut through the confusion.
Geartopia makes gear assemblies like in the following picture.
A gear assembly is a sequence of gears. In the picture, there are six gears.
Each gear has a fixed number of teeth. In the picture, going from left to right, the gears have 12, 12, 8, 12, 12, and 8 teeth, respectively. Assume the teeth of adjacent gears are properly enmeshed; that is, as one gear turns, the adjacent gear turns with no slippage.
What we want to know is, given the leftmost gear is rotating at a constant rotational speed of n rotations a second, how many rotations a second is the rightmost gear rotating?
The input starts with a single integer n, the number of test cases (gear assemblies). Each test case begins with a single integer m, the number of gears in the assembly. Then m integers follow which report the number of teeth each of the m gears has, from left to right, respectively. A final real number follows which states the rotational speed of the leftmost gear. A negative number indicates a counter-clockwise rotation; a positive number indicates a clockwise rotation.
You can assume that, for each test case of m gears, that 2 ≤ m ≤ 200, and, for the number of test cases n, that 1 ≤ n ≤ 1,000. For each number of teeth, t, 4 ≤ t ≤ 1,024. The rotational speed (rotations per second) r will be a float (a double), -100.0 ≤ r ≤ 100.0.
2 6 12 12 8 12 12 8 -1.5 4 7 17 25 13 1.0
For each output scenario, write out the rotational velocity (rotations per second) of the rightmost gear. Provide a precision of three digits to the right of the decimal point.
2.250 -0.538