Editorial for Facebook Hacker Cup '17 Qualifying Round P3 - Fighting the Zombie
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.
Submitting an official solution before solving the problem yourself is a bannable offence.
For each attack, we need to compute the probability that it rolls at least
Let
for (We can always do at least damage) for (We can't do a positive amount of damage with dice)
This last formula combines the outcomes of all possible die rolls for a single die, and weights them evenly by
In this way, we can compute the probability of success for each attack in
Since the most damage we can do is
Comments