Let ${\cal P}_n$ be the set of words
with exactly
opening parentheses and
closing parentheses, such that every ‘)’ matches a
‘(’. For instance, $${\cal P}_3
\enspace = \enspace \{
\enspace \mbox{``\texttt{\small ((()))}''} \enspace,
\enspace \mbox{``\texttt{\small (()())}''} \enspace,
\enspace \mbox{``\texttt{\small (())()}''} \enspace,
\enspace \mbox{``\texttt{\small ()(())}''} \enspace,
\enspace \mbox{``\texttt{\small ()()()}''} \enspace
\} \enspace .$$
Consider the following experiment: Choose one word
from ${\cal P}_n$ at random. Then, pick
one ‘(’ and one ‘)’ of
,
independently at random, and swap them. What is the probability that the
result is also a word in ${\cal
P}_n$?
For example, let
.
If we choose
“((()))”, then there are exactly four swaps that produce a
word in ${\cal P}_3$, namely 2-4, 2-5,
3-4, 3-5. The rest of swaps (1-4, 1-5, 1-6, 2-6, 3-6) are incorrect.
Each of the other words in ${\cal P}_3$
has three correct swaps. Therefore, the probability for
is
Input consists of several integer numbers between 1 and 30.
For every given
,
print with six digits after the decimal point the probability that
swapping a random ‘(’ with a random ‘)’ of a
random word in ${\cal P}_n$ produces a
word also in ${\cal P}_n$.
Input
1 2 3 10 30
Output
0.000000 0.250000 0.355556 0.585699 0.731991