﻿ Fuzhou University OnlineJudge ﻿
Problem 1392 Linear Board Game

## Problem Description

The linear board in this problem is simply a row of n squares numbered from 1 (left most) to n (right most). Each square contains either a treasure or nothing. The player will always starts in the first square. In each turn, he will roll two dices and than move forward m steps where m is he sum of the face numbers of the two rolled dices. If he stops on a square which contains a treasure, he will get one treasure point. The game is finished if he moves out of the board. (If he stops on the nth square, he should continue to play although he is guaranteed to be out in next turn.)

Given the complete information of the linear board, you need to compute the expected value of the treasure point the player will get when the game is finished. To avoid confusion, the first square is always empty.

## Input

The input starts with an integer N (N < 150) which indicates the number of test cases followed. Each of the following N case consists of one input line. The line contains only one string which is the linear board. "." means empty square and "T" means a square with treasure. The length of the string (i.e. the size of the linear board) is guaranteed to be at least 2 and at most 100.

## Output

For each input, output the expected treasure point in a single line with 6 digits after the decimal point.

## Sample Input

9 .. .T .... .T.T .TTT ...................T ....TT..T..TTTT..T.T ..T.T..TT..T.TT.T.T.T.T..T.T.TTT.TTTT...TT..T..T...TTT.TT..T .TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT

## Sample Output

0.000000 0.000000 0.000000 0.055556 0.083333 0.142886 1.194170 4.156287 8.059523

## Source

2005 HKUST Local Contest

Submit  Back  Status  Discuss
﻿