Ultraviolet A 11021-Tribles (probability)
Question connection: Ultraviolet A 11021-Tribles
K of them are only poll, each of which only lives for one day. before death, some new poll may be generated. The probability of I being born is P. Given m, calculate the probability that all the balls will die after m days.
Solution: the probability of death of a ball after m days is f (m). From the full probability formula f (I) = P0 + P1? F (I? 1) + P2? F (I? 1) 2 ..., Therefore, if k is used as a ball, f (m) k is available.
/********************* Pi indicates the probability of birth of the I. Ma. * fi indicates that only one Ma is in the I day. the probability of inner death ********************/# include
# Include
# Include
# Include using namespace std; const int maxn = 1005; int n, k, m; double p [maxn], f [maxn]; int main () {int cas; scanf ("% d", & cas); for (int kcas = 1; kcas <= cas; kcas ++) {scanf ("% d ", & n, & k, & m); for (int I = 0; I <n; I ++) scanf ("% lf", & p [I]); f [0] = 0; f [1] = p [0]; for (int I = 1; I <= m; I ++) {f [I] = 0; for (int j = 0; j <n; j ++) f [I] + = p [j] * pow (f [I-1], j);} printf ("Case # % d: %. 7lf \ n ", kcas, pow (f [m], k);} return 0 ;}