No.162 8020 Campaign
タグ : / 解いたユーザー数 64
作問者 : 👑
kmjp
Problem Statement
Every year on his birthday, yuki-kun has a dental checkup, and if any cavities are found, the decayed teeth are extracted on the spot.
Today is yuki-kun's A-th birthday and he had his dental checkup, but even past the age of sixty he still does not have a single cavity.
Therefore, yuki-kun's teeth (excluding the already extracted wisdom teeth at both ends) are neatly lined up, 14 each on the top and the bottom.
yuki-kun's eye was suddenly caught by the phrase "8020 Campaign" on a poster at the clinic.
It is a campaign to keep at least 20 teeth by the age of 80.
After seeing the poster, yuki-kun became curious how many teeth would remain when he finishes the dental checkup on his 80th birthday.
The probability that a tooth develops a cavity during a year is determined by the presence or absence of its left and right neighboring teeth after the most recent checkup (added at 23:40), because this changes how easy the tooth is to brush and how easily it gets dirty.
Given the current age and the probabilities of developing a cavity, find the expected number of yuki-kun's teeth remaining after the dental checkup on his 80th birthday.
Input
\(A\) \(P_0\) \(P_1\) \(P_2\)
\(A\) is yuki-kun's current age, and is an integer satisfying \(60 \le A \le 79\).
\(P_0, P_1, P_2\) are the probabilities, in percent, that a tooth in each of the following states develops a cavity by the next birthday, and are integers satisfying \(0 \le P_i \le 100\).
- \(P_0\) : a tooth whose neighboring teeth on both sides have been extracted
- \(P_1\) : a tooth whose neighboring tooth on one side has been extracted
- \(P_2\) : a tooth whose neighboring teeth on both sides remain
Output
Output on one line the expected number of yuki-kun's teeth remaining after the dental checkup on his 80th birthday.
An error of up to \(10^{-6}\) is allowed.
Sample
Sample 1
Input
79 80 40 30
Output
19.2
yuki-kun will turn 80 in one more year.
The teeth at both ends of the top and the bottom, 4 teeth in total, remain the next year with a probability of 60%.
The other 24 teeth remain the next year with a probability of 70%.
Sample 2
Input
70 0 0 0
Output
28
Wonderful, yuki-kun did not have a single cavity until the age of 80.
Sample 3
Input
65 7 8 9
Output
7.960459592
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。