spoj#PONY3. Discords Dilemma
Discords Dilemma
Discord is in trouble for causing discord, so he is trying to escape from Equestria. He's arrived at the port, and he doesn't care what boat he gets on, he just wants to get out. He can see the boat schedule, where he sees that N boats are arriving today,
boat 1 arrives any time within a_1 minutes
boat 2 arrives any time within a_2 minutes
...
boat N arrives any time within a_N minutes (uniform distribution)
Tell discord the expected number of minutes he needs to wait for a boat to arrive.
For some reason, you should be accurate to 10^-6 of a minute.
Input Format:
T (number of test cases)
N1 (number of boats for test case 1)
a1 a2 ... aN
N2
...
NT
...
Output Format:
answer1
answer2
...
answerT
Limits:
1 <= T <= 100
1 <= N <= 100
1 <= ai <= 1000
Also, N * max{ai} <= 10000
Sample Input: 4 1 5 3 49 50 51 3 50 50 50 3 2 7 19Note: Round however Java would round if you used the statement System.out.printf("%.6f\n", answer);</p>Sample Output:
2.500000 12.495000 12.500000 0.874687 (Fixed thanks to )