問題一覧 > 通常問題

No.813 Yuki-chan's Adventure

レベル : / AI推定難易度 : 1800 / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 小数誤差許容問題 絶対誤差または相対誤差が $10^{-3}$ 以下。ただし、ジャッジ側の都合で500桁未満にしてください
タグ : (AC するまで非表示) / 解いたユーザー数 82
作問者 : 37zigen / テスター : square1001
お気に入りにしたユーザー ProblemId : 2260 / 自分の提出
問題文最終更新日: 2022-01-29 03:26:55
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 210 (順位表) の他の問題:

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もしくは右上の雲マークをクリックしてアカウントを作成してください。