题目链接
1 #include <bits/stdc++.h>
2 using namespace std;
3 typedef long long ll;
4 inline ll read(){
5 int x=0,f=1;char ch=getchar();
6 while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
7 while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
8 return x*f;
9 }
10
11 /***********************************************************/
12
13 const int maxn = 1e6+7;
14 double dp[maxn][3];
15
16 int main(){
17 int n;
18 n = read();
19 for(int i = 1;i <= n;i++){
20 double x;
21 scanf("%lf", &x);
22 dp[i][0] = (dp[i-1][0] + 1)*x;
23 dp[i][1] = (dp[i-1][1] + 2*dp[i-1][0] + 1) * x;
24 dp[i][2] = dp[i-1][2] + (3*dp[i-1][1] + 3*dp[i-1][0] + 1) * x;
25 }
26 printf("%.1lf
", dp[n][2]);
27 return 0;
28 }