POJ2151 Check The difficulty of problems probability DP

Source: Internet
Author: User
Description

Organizing a programming contest is not an easy job. To avoid making the problems too difficult, the organizer usually expect the contest result satisfy the following S:
-All of the teams solve at least one problem.
-the champion (one of those teams that solve the most problems) solves at least a certain number of problems.
Now the organizer have studied out the contest problems, and through the result of preliminary contest, the organizer Can estimate the probability that a certain team can successfully solve a certain problem.
Given the number of contest problems M, the number of teams T, and the number of problems N that the organizer expect The champion solve at least. We also assume that team I solves problem J with the probability Pij (1 <= i <= T, 1<= J <= M). Well, can-calculate the probability, all of the teams solve at least one problem, and at the same time the Champio N team solves at least n problems?

Test Instructions
There are M-m questions, T-T teams, give all teams the probability of solving each problem separately Pij P_{ij}, ask each team to solve at least 1 questions and the championship team to solve the probability of at least n N.

parsing
Involve at least this word, you might as well use some prefixes and tricks.
Assuming P1 p1 is the probability that all teams can solve up to M m, p2 P2 is the probability that all teams will solve the problem of up to n−1 N-1, then the final answer is P1−P2 p1-p2.
We need to calculate each team's contribution separately, and then multiply the corresponding answers to calculate P1 p1, p2 p2.
Set F[i][j] F[i][j] represents the current problem of the first I I, solved the probability of a total J-J problem. It is not difficult to find the transfer equation
F[i][j]=f[i−1][j−1]xp[i][j]+f[i−1][j]x (1−p[i][j]) f[i][j] = F[i-1][j-1] \times p[i][j] + f[i-1][j] \times (1-p[i][j])
Then use Sum[i] sum[i to represent the probability of solving the problem of up to I I in all problems, in fact, is the prefix and.
So the team for P1 P1 contribution is sum[m]−sum[0] sum[m]-sum[0], p2 P2 contribution is sum[n−1]−sum[0] sum[n-1]-sum[0].

array can roll, you don't have to roll it's okay

 #include <iostream> #include <cstdio> #include <cstdlib> #include < cstring> #include <map> #include <vector> #include <cmath> #include <queue> #include < stack> #include <algorithm> #include <cctype& 

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.