[Offer收割]编程练习赛14 register

Ended

Participants:574

Verdict:Accepted
Score:100 / 100
Submitted:2017-04-16 12:25:43

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;
const int maxn = 1000 + 10;
const float pi = acos(-1.0);
typedef long long int LLI;
double dp[maxn][maxn];
int main() {
//    freopen("in.txt","r",stdin);
    int n,m;
    scanf("%d%d",&n,&m);
//    memset(dp,1,sizeof(dp));
    dp[0][0] = 1;
    for(int i = 1;i <= n;i ++){
        double p;
        scanf("%lf",&p);
        for(int j = 0;j <= i;j ++){
            if(j == 0)  dp[i][j] = dp[i - 1][j] * (1 - p);
            else        dp[i][j] = dp[i - 1][j - 1] * p + dp[i - 1][j] * (1 - p);
        }
    }
//    printf("%f\n",dp[1][0]);
//    printf("%f\n",dp[1][1]);
    printf("%f\n",dp[n][m]);
    return 0;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX