hiho week 264 register

Ended

Participants:100

Verdict:Accepted
Score:100 / 100
Submitted:2019-07-26 20:56:00

Lang:G++

Edit
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
#include<bits/stdc++.h>
using namespace std;
int n,m;
double p[2000];
double d[2][2000];
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++)scanf("%lf",&p[i]);
    memset(d,0,sizeof d);
    d[0][0]=1;
    int now=1,pre=0;
    for(int i=1;i<=n;i++)
    {
        for(int j=0;j<i;j++)
        {
            d[now][j]+=d[pre][j]*(1-p[i]);
            d[now][j+1]+=d[pre][j]*p[i];
        }
        memset(d[pre],0,sizeof d[pre]);
        now^=1;
        pre^=1;
    }
    printf("%.6lf\n",d[pre][m]);
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX