hiho week 264 register

Ended

Participants:100

Verdict:Accepted
Score:100 / 100
Submitted:2019-07-24 17:28:02

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
#include<iostream>
using namespace std;
float arr[1024][1024]={0};
int main(){
    int M,N;
    float p[1024]={0};
    float np[1024]={0};
    cin>>N>>M;
    for(int i=1;i<=N;i++){
        cin>>p[i];
        np[i] = 1-p[i];
    }
    arr[1][0] = np[1];
    arr[1][1] = p[1];
    for(int i = 2;i<=N;i++){
        for(int j=0;j<=M;j++){
            arr[i][j] = arr[i-1][j] *np[i] ;
            if(j>0){
                arr[i][j]+=arr[i-1][j-1] *p[i];
            }
        }
    }
    cout<<arr[N][M]<<endl;
} 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX