# [BZOJ4318] OSU!

$E(x + \Delta) = E(x) + E(\Delta)$

$E(x ^ 2)$的增量为$2E(x) + 1$

### Code

#include<bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = (a), i##_end_ = (b); i <= i##_end_; ++i)
#define drep(i, a, b) for(int i = (a), i##_end_ = (b); i >= i##_end_; --i)
#define clar(a, b) memset((a), (b), sizeof(a))
#define debug(...) fprintf(stderr, __VA_ARGS__)
typedef long long LL;
typedef long double LD;
char ch = getchar();
int x = 0, flag = 1;
for (;!isdigit(ch); ch = getchar()) if (ch == '-') flag *= -1;
for (;isdigit(ch); ch = getchar()) x = x * 10 + ch - 48;
return x * flag;
}
void write(int x) {
if (x < 0) putchar('-'), x = -x;
if (x >= 10) write(x / 10);
putchar(x % 10 + 48);
}

const int Maxn = 100009;
int n;
double f[Maxn];
double Expection[Maxn][4];
double g[Maxn];

void init() {
rep (i, 1, n) scanf("%lf", &f[i]);
}

void solve() {
rep (i, 1, n) {
Expection[i][1] = (Expection[i - 1][1] + 1) * f[i];
Expection[i][2] = (Expection[i - 1][2] + 2 * Expection[i - 1][1] + 1) * f[i];
Expection[i][3] = Expection[i - 1][3] + (3 * Expection[i - 1][2] + 3 * Expection[i - 1][1] + 1) * f[i];
}

printf("%.1lf\n", Expection[n][3]);
}

int main() {
freopen("BZOJ4318.in", "r", stdin);
freopen("BZOJ4318.out", "w", stdout);

init();
solve();

#ifdef Qrsikno
debug("\nRunning time: %.3lf(s)\n", clock() * 1.0 / CLOCKS_PER_SEC);
#endif
return 0;
}
posted @ 2019-01-27 00:53 Qrsikno 阅读(...) 评论(...) 编辑 收藏