Q37: Probability of passing exam by guessing
10 multiple choice (abcd 4 choices) questions , pass = at least 5/10 questions are guessed correctly, how possible is that you can pass the exam just by guessing?
最初想复杂了,感觉要实现C(n, k) 然后分情况累加
计算概率的一道题,但是实际为DP!!!!!!!
p = 1/4;
dp[n + 1][ k + 1]
dp[1][1] = 1;
dp[1][0] = 0;
j == 0 dp[i][j] = dp[i -1][j] * (1- p)
dp[ i ][ j ] = dp[ i -1] [j -1] * p + dp [ i -1] [j] * (1- p); // 全从前i 个里选和不从前i 个里选
return dp[ n] [k]
代码略