标签:
1、题意:一个序列,连续的一段1对得分具有
2、分析:一道裸的期望dp,那么新加入一个1,对答案的贡献为
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
#define M 1000010
inline int read(){
char ch = getchar(); int x = 0, f = 1;
while(ch < ‘0‘ || ch > ‘9‘){
if(ch == ‘-‘) f = -1;
ch = getchar();
}
while(‘0‘ <= ch && ch <= ‘9‘){
x = x * 10 + ch - ‘0‘;
ch = getchar();
}
return x * f;
}
double l[M], l2[M], f[M];
int main(){
int n = read();
for(int i = 1; i <= n; i ++){
double x; scanf("%lf", &x);
l[i] = (l[i - 1] + 1) * x;
l2[i] = (l2[i - 1] + 2 * l[i - 1] + 1) * x;
f[i] = f[i - 1] + (3 * l2[i - 1] + 3 * l[i - 1] + 1) * x;
}
printf("%.1lf\n", f[n]);
return 0;
}
标签:
原文地址:http://blog.csdn.net/qzh_1430586275/article/details/51894635