z-lastchar
A long string is composed by concatenating N times the string S. From the resulting string all the characters at odd positions are removed.Then from the string that remains, again all the characters at odd positions are removed.The process continues until there is only one character left.
Your task is to write a program that finds the last character.
Example: The string PROFILE is written 2 times
--------------------
PROFILEPROFILE
----------------------
-R-F-L-P-O-I-E
-------------------
RFLPOIE
---------------
-F-P-I-
-----------
FPI
---------
-P-
----------
P
------------
So the last character is "P" .
Input In the first line will be the string S, (1<=length(S)<=250), containing only capital letters. The second line will contain N, (1<=N<=1000000000) , number of times the string S is concatenated.
OutputThe output should contain a string, of length 1, which contains only the last remaining character. Don't forget to output the END LINE character after it!
Input
Output
PROFILE
2Output
PInput
Output
ABC
10Output
ASubmit solution
Coming laterThe grading service will be connected in a later migration step. You can inspect the task and your previous results now.