HRY and codefire
题号:NC25394
时间限制:C/C++/Rust/Pascal 1秒,其他语言2秒
空间限制:C/C++/Rust/Pascal 256 M,其他语言512 M
64bit IO Format: %lld

题目描述

As is all known, yang12138 is a pupil. He registered two accounts on codefire. The two accounts are both at level 0 initially, and the level is at most n. Every time he wins, the level will increase by 1, but if he loses, the level will not change. When using an account at level i, the winning probability of yang12138 is p_i.

Someone who reaches level n is called a GrandMaster in codefire. yang12138 has a dream of being a GrandMaster, so he is trying hard. His strategy is as follows:

1. Randomly pick an account to take part in a competition at first.
2. Assume that he is currently using account A, if he wins, he continues using account A to take part in competitions. Otherwise he will use the other account.
3. When any of his account reaches level n, stop immediately, because yang12138 has become a GrandMaster .

Given probability of winning of yang12138 at each level. As a GrandMaster, please calculate the expected competition times of yang12138 to become a GrandMaster.


输入描述:

The first line of input contains an integer T, indicating the number of test cases.

For each test case there are two lines :

The first line contains an integer n.

The second line contains $n$ real numbers , indicating the probability of winning when using an account at level i.


输出描述:

For each test case output a real number, rounded to 4 decimal places.
示例1

输入

复制
2
1
0.5
2
0.5 0.5

输出

复制
2.0000
4.6667