eolymp
bolt
Try our new interface for solving problems
Problems

Fibonacci Strings

Fibonacci Strings

Fibonacci sequence of strings is defined as follows: \begin{itemize} \item $s_1 = "b"$, \item $s_2 = "a"$, \item $s_k = s_{k-1} + s_{k-2}$ for $k > 2$ \end{itemize} For example, $s_3 = "ab", s_4 = "aba", s_5 = "abaab"$ and so on. Given positive integers $n, m, l$. Print the substring of $s_n$ which starts at position $m$ and have the length $l$. \InputFile One line contains three space-separated positive integers $n, m$ and $l~(1 \le n \le 40; 1 \le m \le length(S_n), 1 \le l \le 1000)$. \OutputFile Print the substring of $s_n$ which starts at position $m$ and have the length $l$ (the length of the printed substring may be less if the length of the remainder of the string $s_n$, starting from position $m$, is less than $l$).
Time limit 1 second
Memory limit 128 MiB
Input example #1
5 3 2
Output example #1
aa
Input example #2
5 3 10
Output example #2
aab