Hdu4336 card collector probability + rejection

Source: Internet
Author: User

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 
        
       
      
     
    
   
  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.