#P1885. Moo String Game
Moo String Game
Moo String Game
Bessie the cow is learning string operations and constructs new strings by following a special set of rules. The process begins with:
\( S(0) = \texttt{moo} \)
For \( k \ge 1 \), the string \( S(k) \) is constructed by the following recursive formula:
\( S(k) = S(k-1) + \texttt{m} + \texttt{o}^{(k+2)} + S(k-1) \)
That is, \( S(k) \) is formed by concatenating \( S(k-1) \), then the letter m
, then \( k+2 \) copies of the letter o
, and finally \( S(k-1) \) again.
Bessie continues this process until the length of the final string is at least \( N \) (with \( 1 \le N \le 10^9 \)). Your task is to determine whether the \( N\)th character of the resulting string is m
or o
.
Note: The indexing is 1-based.
inputFormat
The input consists of a single integer \( N \) representing the position in the string.
Constraints: \( 1 \le N \le 10^9 \)
outputFormat
Output a single character: m
or o
, which is the \( N \)th character of the string.
sample
1
m