No.1501 Random Walk
問題文最終更新日: 2021-05-08 01:20:03
English (AI translation)
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 294
(順位表)
の他の問題:
Problem Statement
There are $N$ cells numbered from $1$ to $N$ and $1$ piece. Initially, the piece is placed on cell $K$.
An integer is written on each cell, and $A_i$ is written on cell $i$. You repeat the following action until the piece reaches cell $1$ or cell $N$.Constraints
Input
$N\ K$ $A_1\ A_2\ \ldots\ A_N$
Output
The required probability can be expressed as $\displaystyle\frac pq$ using coprime integers $p,q$ $(0\le p,0< q)$ (these $p,q$ are uniquely determined). Output $p$ and $q$ separated by /.
0.
Sample
Sample 1
Input
3 2 1 1 2
Output
2/3
The piece goes to cell $1$ with probability $\displaystyle\frac13$ and to cell $3$ with probability $\displaystyle\frac23$.
Either way, it reaches cell $1$ or cell $N=3$, so the answer is $\displaystyle\frac23$.Sample 2
Input
5 1 1 2 3 4 5
Output
0
The piece has already reached cell $1$.
Sample 3
Input
7 3 1 1 2 2 1 2 2
Output
1/2
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
nok0