P1409 Dice

Description

$n$ people stand in a line, and you are the $m$-th. In each round, the person at the front of the queue rolls a die once. - If they roll $1$, the person at the front wins. - If they roll $2, 4, 6$, the person at the front moves to the end of the queue. - If they roll $3, 5$, the person at the front leaves the queue. If only one person remains in the queue, that person wins. Find the probability that you win.

Input Format

One line containing two integers $n, m$.

Output Format

A real number representing the winning probability, to $9$ digits after the decimal point.

Explanation/Hint

- For $30\%$ of the testdata, $0 < m \le n \le 10$. - For $100\%$ of the testdata, $0 < m \le n \le 1000$. Translated by ChatGPT 5