No.813 Yuki-chan's Adventure
タグ : / 解いたユーザー数 82
作問者 :
37zigen
/ テスター :
Problem Statement
There are $N$ gates lined up in the range $x>0$ on the $x$-axis.
The gates are numbered $1$,$2$,...,$N$ in increasing order of $x$-coordinate.
Yuki-chan, who is at the origin $x=0$, is trying to get beyond the $N$ gates.
When Yuki-chan reaches the $i$-th($1≦i≦N$) gate, an ogre appears.
Note that the ogre appears again even if she has previously defeated the ogre that appeared at this gate and passed through it.
The strength of the ogre is the same regardless of the gate number.
With probability $p$, Yuki-chan runs away from the ogre and moves in the direction opposite to the one she has been moving in.
With probability $q$, Yuki-chan defeats the ogre and passes through gate $i$.
With probability $1-p-q$, Yuki-chan is defeated by the ogre.
Find the probability $r$ that she returns to the origin without ever reaching beyond the $N$ gates and without being defeated.
Input
$N$ $p$ $q$
- $1≦N≦10^3$
- $p$, $q$ are given with up to 18 decimal places.
Output
Output the probability $r$ that Yuki-chan returns to the origin without ever reaching beyond the $N$ gates and without being defeated.
Your answer is accepted if the smaller of the relative error and the absolute error is within $0.001$.
Print a newline at the end.
Sample
Sample 1
Input
10 1 0
Output
1
Yuki-chan always runs away and returns to the origin.
Sample 2
Input
720 0.125163881220761270 0.178332892386225570
Output
0.12934508476159298
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。