解法1:メモ化再帰
考え方
$f(n)=$1から初めて最終的にピッタリ$n$になる確率.- $n=1$:$f(1)=1$
- $n\neq 1$:$\displaystyle f(n) = \frac{1}{6} \sum_{k} f(n/\!/k)$($(n\% k =0$かつ$k \in \{1,2,\ldots,6\})$)
$n\neq 1$の場合,
\begin{aligned}
f(n) = \frac{1}{6} f(n)+ \frac{1}{6} \sum_{k\neq 1} f(n/\!/k)
\end{aligned}
だからf(n) = \frac{1}{6} f(n)+ \frac{1}{6} \sum_{k\neq 1} f(n/\!/k)
\end{aligned}
\begin{aligned}
f(n) = \frac{1}{5} \sum_{k\neq 1} f(n/\!/k)
\end{aligned}
f(n) = \frac{1}{5} \sum_{k\neq 1} f(n/\!/k)
\end{aligned}