SAC '22 Code Challenge 3 Junior P3 - Normal Probabilities

View as PDF

Submit solution


Points: 3 (partial)
Time limit: 1.0s
Memory limit: 256M

Author:
Problem type

After discovering the 5 normalized probabilities, Kevin Yang was awarded the Nobel Prize for mathematics.

With this discovery, Kevin can solve even more combinatorics problems.

One of the combinatorics problems entails a list of N events that each have a normalized probability P_i of occurring.

Since these are normalized probabilities, there are 5 types of probability:

  • A corresponds to a 100% probability of occurring.

  • B corresponds to an 80% probability of occurring.

  • C corresponds to a 60% probability of occurring.

  • D corresponds to a 40% probability of occurring.

  • E corresponds to a 20% probability of occurring.

Kevin wants to know how likely it is that all these N events occur (assuming each event is independent) up to an error of 10^{-6}.

Constraints

1 \le N \le 100\,000

P_i \in \{A,B,C,D,E\}

Input Specification

The first line will contain N, the number of independent events.

The next N lines will contain P_i, one of the normalized probabilities (A, B, C, D, or E).

Output Specification

Output the probability of all N events occurring up to an error of 10^{-6}.

Sample Input 1

3
A
B
B

Sample Output 1

0.640000

Sample Input 2

4
B
C
D
E

Sample Output 2

0.038400

Comments

There are no comments at the moment.