Discovering Gold(期望)

You are in a cave, a long cave! The cave can be represented by a1 x Ngrid. Each cell of the cave can contain any amount of gold.

Initially you are in position1. Now each turn you throw a perfect6sided dice. If you getXin the dice after throwing, you addXto your position and collect all the gold from the new position. If your new position is outside the cave, then you keep throwing again until you get a suitable result. When you reach theNthposition you stop your journey. Now you are given the information about the cave, you have to find out theexpectednumber of gold you can collect using the given procedure.

Input

Input starts with an integerT (≤ 100), denoting the number of test cases.

Each case contains a blank line and an integerN (1 ≤ N ≤ 100)denoting the dimension of the cave. The next line containsNspace separated integers. Theithinteger of this line denotes the amount of gold you will get if you come to theithcell. You may safely assume that all the given integers will be non-negative and no integer will be greater than1000.

Output

For each case, print the case number and the expected number of gold you will collect. Errors less than10-6will be ignored.

Sample InputOutput for Sample Input

3

1

101

2

10 3

3

3 6 9

Case 1: 101.0000000000

Case 2: 13.000

Case 3: 15

,都会有回报,愿你天天开心。

Discovering Gold(期望)

相关文章:

你感兴趣的文章:

标签云: