Problem Statement
$N$ people numbered $1$ to $N$ are standing in a circle, in the clockwise order of Person $1$, Person $2$, $\cdots$, Person $N$. The direction each person faces is given by a string $S$ of length $N$. For each $i$ $(1 \leq i \leq N)$, Person $i$ is facing in the counter-clockwise direction if $S_i =$ L, and clockwise direction if $S_i =$ R.
The following operation will be repeated $N-1$ times.
- Choose one of the remaining people with equal probability, and remove from the circle the nearest person seen from the chosen person. This incurs a cost equal to the distance from the chosen person to the removed person.
Here, the distance from Person $i$ to Person $j$ $(i \neq j)$ is defined as follows.
- When Person
$i$is facing in the clockwise direction:
$j-i$if$i \lt j$;$j-i+N$if$i \gt j$.
- When Person
$i$is facing in the counter-clockwise direction:
$i-j+N$if$i \lt j$;$i-j$if$i \gt j$.
Find the expected value of the total cost incurred, modulo $998244353$ (see Notes).
Note
It can be proved that the sought expected value is always a rational number. Additionally, under the Constraints of this problem, when that value is expressed as $\frac{P}{Q}$ using two coprime integers $P$ and $Q$, there is a unique integer $R$ such that $R \times Q \equiv P\pmod{998244353}$ and $0 \leq R \lt 998244353$. Find this $R$.
Constraints
$2 \leq N \leq 300$$N$is an integer.$S$is a string of length$N$consisting ofLandR.
Input
Input is given from Standard Input in the following format:
N
S
Output
Print the answer.
样例
3
LLR
831870297
10
RRRRRRLLRR
460301586
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。