做题记录 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;
}
上一篇:与众不同 windows phone (50) - 8.1 新增控件: PickerFlyout, ListPickerFlyout


下一篇:《Windows核心编程》读书笔记 上