- #include<iostream>
- #include<stdio.h>
- #include<cstring>
- using namespace std;
- int main()
- {
- int t;
- cin>>t;
- int a[110];
- double dp[110];
- for(int i=1;i<=t;i++)
- {
- memset(a,0,sizeof(a));
- memset(dp,0,sizeof(dp));
- dp[1]=1;
- int n,h;
- double ans=0;
- cin>>n;
- for(int j=1;j<=n;j++)
- cin>>a[j];
- for(int j=1;j<=n;j++){
- if(n-j<6)
- h=n-j;
- else
- h=6;
- for(int k=1;k<=h;k++)
- {
- dp[j+k]+=dp[j]*1.0*1/h;
- }
- ans+=1.0*a[j]*dp[j];
- }
- printf("Case %d: %lf\n",i,ans);
- }
- return 0;
- }
来源: http://www.bubuko.com/infodetail-2571076.html