eolymp
bolt
Попробуйте наш новый интерфейс для отправки задач
Задачи

Look-and-Say sequences

Look-and-Say sequences

A look-and-say sequence is a sequence of integers, expressed in decimal notation, where each sucessive term is generated by describing the previous one. For instance, if \textbf{x_1} (the first term of the sequence) is \textbf{1}, the next term is the description of this term, \textbf{11} ("one \textbf{1}"), which is described by \textbf{21} ("two \textbf{1}'s"), which is described by \textbf{1211} ("one \textbf{2} one \textbf{1}"), etc.; the series continues \textbf{111221}, \textbf{312211}, \textbf{13112221}, ... Your problem is to build a program that, given the first term of a look-and-say sequence \textbf{x_1}, calculates the \textbf{j}-th digit of the \textbf{i}-th term, \textbf{x_i}. \InputFile \includegraphics{http://uva.onlinejudge.org/external/116/11660img2.png} \includegraphics{http://uva.onlinejudge.org/external/116/11660img3.png} Each line in the input corresponds to a test case specified by \textbf{3} integer values: \textbf{x_1}, \textbf{i} and \textbf{j}, with \textbf{1 ≤ x_1}_\{ \}\textbf{≤ 1000}, \textbf{1} \textbf{≤ i}\textit{ }\textbf{≤ 1000} and \textbf{1 ≤ j}\textit{ }\textbf{≤ min}(\textbf{log_10}(\textbf{x_i}) + \textbf{1}, \textbf{1000}). The end of the input is indicated by a line "\textbf{0 0 0}". \OutputFile For each test case, the program must output a line with the \textbf{j}-th digit of the term \textbf{x_i} of the look-and-say sequence that starts with the term \textbf{x_1}.
Лимит времени 3 секунды
Лимит использования памяти 64 MiB
Входные данные #1
1 3 1
1 3 2
1 7 2 
123 3 1 
0 0 0
Выходные данные #1
2
1
3
3