HDU 4336 probability dp-like pressure

Source: Internet
Author: User

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

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.