-
Notifications
You must be signed in to change notification settings - Fork 0
/
P1654.cpp
72 lines (68 loc) · 1.27 KB
/
P1654.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include <bits/stdc++.h>
#define INF 999999999
using namespace std;
inline long long read()
{
long long x = 0;
int f = 1;
char ch = getchar();
while (ch < '0' || ch > '9')
{
if (ch == '-')
f = -1;
ch = getchar();
}
while (ch >= '0' && ch <= '9')
{
x = (x << 1) + (x << 3) + (ch ^ 48);
ch = getchar();
}
return x * f;
}
void write(const long long &x)
{
if (!x)
{
putchar('0');
return;
}
char f[100];
long long tmp = x;
if (tmp < 0)
{
tmp = -tmp;
putchar('-');
}
long long s = 0;
while (tmp > 0)
{
f[s++] = tmp % 10 + '0';
tmp /= 10;
}
while (s > 0)
{
putchar(f[--s]);
}
}
const long long maxN = 100090;
long double X1[maxN];
long double X2[maxN];
long double ANS[maxN];
long double P[maxN];
long long totN;
int main()
{
totN = read();
for (int i = 1; i <= totN; i++)
{
scanf("%Lf", &P[i]);
}
for (int i = 1; i <= totN; ++i)
{
X1[i] = P[i] * (X1[i - 1] + 1);
X2[i] = P[i] * (X2[i - 1] + 2 * X1[i - 1] + 1);
ANS[i] = ANS[i - 1] + P[i] * (3 * X2[i - 1] + 3 * X1[i - 1] + 1);
}
printf("%.1LF", ANS[totN]);
return 0;
} //Thomitics Code