Expected n cards.
Card collector
Time Limit: 2000/1000 MS (Java/others) memory limit: 32768/32768 K (Java/Others)
Total submission (s): 1700 accepted submission (s): 776
Special Judge
Problem descriptionin your childhood, do you crazy for collecting the beautiful cards in the snacks? They said that, for example, if you collect all the 108 people in the famous novel Water Margin, you will win an amazing award.
As a smart boy, you notice that to win the award, you must buy much more snacks than it seems to be. to convince your friends not to waste money any more, you should find the expected number of snacks one shoshould buy to collect a full suit of cards.
Inputthe first line of each test case contains one integer N (1 <= n <= 20), indicating the number of different cards you need the collect. the second line contains N numbers P1, P2 ,..., pn, (P1 + p2 +... + PN <= 1), indicating the possibility of each card
Appear in a bag of snacks.
Note there is at most one card in a bag of snacks. And it is possible that there is nothing in the bag.
Outputoutput one number for each test case, indicating the expected number of bags to buy to collect all the n different cards.
You will get accepted if the difference between your answer and the standard answer is no more that 10 ^-4.
Sample Input
10.120.1 0.4
Sample output
10.00010.500
Source2012 multi-university training contest 4
Recommendzhoujiaqi2010
# include
# include
# include
# include
# include
using namespace STD; # define maxn 100int N, cur; double ans, TMP; double F [maxn]; int counts (int x) {int CNT = 0; while (x) {CNT ++; X & = (x-1);} return CNT;} int main () {While (CIN> N) {for (INT I = 0; I
F [I]; int cur =-1; ans = 0; int state = (1