hiho week 264 register

Ended

Participants:100

Verdict:Accepted
Score:100 / 100
Submitted:2019-07-21 10:13:33

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
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<double> p(N + 1);
    vector<vector<double>> dp(N + 1, vector<double>(M + 1, 0));
    dp[0][0] = 1;
    for (int i = 1; i <= N; ++i) {
        cin >> p[i];
        dp[i][0] = dp[i - 1][0] * (1 - p[i]);
        for (int j = 1; j <= M; ++j)
            dp[i][j] = dp[i - 1][j] * (1 - p[i]) + dp[i - 1][j - 1] * p[i];
    }
    cout << dp[N][M] << endl;
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX