题解戳这里…大爷传送门
http://blog.csdn.net/PoPoQQQ/article/details/49512533
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
//by:MirrorGray
using namespace std;
const int N=211111;
long double dp[N],f[N][3];
int main()
{
int n;scanf("%d",&n);
for(int i=1;i<=n;i++)
{
double p;scanf("%lf",&p);
f[i][1]=( f[i-1][1]+1 )*p;
f[i][2]=( f[i-1][2]+(f[i-1][1]*2+1) )*p;
dp[i]=dp[i-1]+( (3*f[i-1][2]+3*f[i-1][1]+1) )*p;
}
printf("%.1f\n",(double)dp[n]);
return 0;
}