Let's Do This Thing I
Cady is done trying to act dumb! As the newest member of the North Shore High's Mathletes, she's up against Marymount High in the ICMT State Final Math Championships.
In the first round, the Mathletes will be asked questions in a row. Any member of the Mathletes can attempt answer a question, but no member can attempt to answer a question twice in a row.
Ahead of time, the Mathletes have figured out how likely it is that each of them gets each question correct. If each member chooses to buzz in at the right times, what is the expected number of questions the Matheletes will get correct?
Input
The first line consists of an integer
, the number of Mathletes.
The next line consists of an integer
, the number of questions in the contest.
The next lines contain a string
and integers
, indicating that member
has a
probability of getting the first question correct, a
probability of getting the second question correct, and so on.
can be any string of English characters.
Output
Output the expected number of questions that the Mathletes will get correct.
Clarifications
- Probabilities are given with up to
decimal places of precision.
- Your answer also be correct to
decimal places.
Example
Input
4
4
Tyler 0.5 0.4 0.8 0.1
Kevin 0.9 0.7 0.9 0.4
Tim 0.4 0.6 0.1 0.2
Cady 0.1 0.3 0.8 0.9
Output
3.3000
If the Mathletes buzz in optimally, then:
- Kevin should answer question
, with a
chance of a correct answer.
- Tim should answer question
, with a
chance of a correct answer.
- Kevin should answer question
, with a
chance of a correct answer.
- Cady should answer question
, with a
chance of a correct answer.
Overall, the team should expect to get questions correct.
Comments