题目链接:​​http://www.lightoj.com/volume_showproblem.php?problem=1030​​​
题意:基础概率题。
代码:

#include <stdio.h>
#include <string.h>
#include <vector>
#include <string>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <fstream>
#include <set>
#include <map>
#include <math.h>

using namespace std;

double dp[1010];

int main()
{
int i, j, t, n, ca = 0;
cin >> t;
while (t--)
{
memset(dp, 0,sizeof(dp));
cin >> n;
for (int i = 1; i <= n;i++)
scanf("%lf", &dp[i]);

for (int i = n-1; i >= 1; i--)
for (int j = 1; j <= 6; j++)
dp[i] += dp[i+j] / min(6, n - i);
printf("Case %d: %.6lf\n", ++ca, dp[1]);

}
return 0;
}