Use D (s) to indicate how many packets of small raccoons (which I yy) need to buy when the card type status is S.
Then there is the equation D (s) = 1 + (p (empty) + P (have)) * d (s) + P (none) * D (T)
where P (empty) means that no card is collected, p (yes) means that the card is collected, and P (none) indicates that a new card was collected.
and P (empty) + P (have) + P (None) = 1,t indicates the state after the new card is collected
Finishing after getting D (S) = (1 + d (T))/P (None)
1#include <iostream>2#include <cstdio>3#include <algorithm>4#include <cstring>5 using namespacestd;6 7 Const intMAXN = -;8 Doubled[1100000];9 Doublep[1100000];Ten One intMain () A { - intN; - while(SCANF ("%d", &n) = =1&&N) the { - for(inti =0; I < n; i++) scanf ("%LF", p +i); - intTot = (1<< N)-1; -D[tot] =0; + for(inti = tot-1; I >=0; i--) - { + DoubleWu =0; AD[i] =1; at for(intj =0; J < N; J + +)if((I & (1<< j) = =0) - { -Wu + =P[j]; -D[i] + = p[j] * d[i | (1<<j)]; - } -D[i]/=Wu; in } -printf"%.6f\n", d[0]); to } + - return 0; the}code June
HDU 4336 probability dp-like pressure