做题记录 Luogu CF235B
作者:互联网
CF235B Let's Play Osu! - 洛谷 | 计算机科学教育新生态 (luogu.com.cn)
递推,维护一次的和。
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
int n;
double p[N], x1[N], f[N];
signed main()
{
scanf("%d", &n);
for(int i = 1; i <= n; i++)
{
scanf("%lf", &p[i]);
}
for(int i = 1; i <= n; i++)
{
x1[i] = (x1[i - 1] + 1) * p[i];
f[i] = f[i - 1] + (2 * x1[i - 1] + 1) * p[i];
}
printf("%lf", f[n]);
return 0;
}
标签:Play,cn,记录,int,Luogu,long,CF235B,define 来源: https://www.cnblogs.com/fanypcd/p/15032189.html