Solving Codeforces Edu #99 E (Expected Damage) (finished)