Reading Digits
Time limit0.1sMemory limit256 MB
Decode the given run-length-encoded string k times, then report the digit at index pos of the original string s.
- Level
Medium7 of 10
- Topics
- String, Implementation, Recursion
- Solved
- No attempts yet
Problem
Bob encodes strings of digits in his own way. He reads "1211" as one 1, one 2, two 1s, which gives "111221". Applying the same rule once more gives "312211", and that string is the result of encoding "1211" two times.
You are given the result of encoding a string exactly times. The string contains only non-zero digits, that is digits from 1 to 9, and no digit repeats 10 or more times in a row. Find the digit at position of , counting from 0.
Input
The first line contains and , separated by a space. The second line contains the string obtained by encoding exactly times.
, , and .
Output
Print the digit at position of .