Editorial for SAC '22 Code Challenge 3 Junior P3 - Normal Probabilities


Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.
Submitting an official solution before solving the problem yourself is a bannable offence.

Author: maxcruickshanks

Maintain the probability that all these events occur with a double variable denoted as P and initialized to 1.0.

For each of the following cases, multiply P by their respective probabilities:

If the probability type is A, multiply P by 1.0;

If the probability type is B, multiply P by 0.8;

If the probability type is C, multiply P by 0.6;

If the probability type is D, multiply P by 0.4;

If the probability type is E, multiply P by 0.2.

Finally, output P to 6 decimal places.

Time Complexity: \mathcal{O}(N)

Bonus: Can you find the probability to multiply by without if-statements?

Hint: The probability type and the probability are sequential and decreasing.


Comments

There are no comments at the moment.