#K63327. Ticket Vending Machine Problem

    ID: 31729 Type: Default 1000ms 256MiB

Ticket Vending Machine Problem

Ticket Vending Machine Problem

You are given several ticket vending machines, each with its own probability of dispensing a ticket. Your task is to determine the expected number of passengers required to obtain one ticket from the machine with the highest probability.

Mathematically, if a machine has a probability \(p\) of dispensing a ticket, then the expected number of passengers needed is given by

[ E = \frac{1}{p_{\max}} ]

where \(p_{\max}\) is the maximum probability among the given probabilities. If \(p_{\max} = 0\), then the result is considered to be infinity.

The answer should be printed with 6 decimal places.

inputFormat

The first line of the input contains an integer \(T\) denoting the number of test cases. Each test case consists of two lines:

  • The first line contains an integer \(n\) denoting the number of machines.
  • The second line contains \(n\) space-separated floating-point numbers denoting the probabilities for each machine.

All input is read from standard input (stdin).

outputFormat

For each test case, output a single line containing the expected number of passengers required to obtain one ticket from the machine with the highest probability, formatted to 6 decimal places. All output should be written to standard output (stdout).

## sample
3
3
0.2 0.5 0.8
2
0.1 0.9
4
0.3 0.4 0.6 0.9
1.250000

1.111111 1.111111

</p>