Evolving Etymology
InterviewTime limit1sMemory limit1024 MB
Given a word s of length n, apply the every-second-letter transform k times (k up to 10^18) and print the resulting word.
- Level
Medium5 of 10
- Topics
- Math, Number theory, String
- Solved
- No attempts yet
Problem
Eelco has recently become interested in etymology, the study of where words come from. He especially likes how words change over time: pronunciation shifts, words are borrowed from other languages, and meanings change with culture. Eelco is attending the Networking With Etymologists: Revolutionary Conference for the first time. To make a good first impression, he will present a new method for making words from existing words.
To make a new word from an existing word , take every second letter of , starting with the first letter. For example, applying this method to the word etymology gives eyooytmlg. The process can be repeated many times. Eelco wants a list of new words for the conference, so he is writing a program that applies the method a fixed number of times.
Input
The first line contains two integers and (, ), the length of the original word and the number of times to apply the method.
The second line contains a string of length , consisting only of lowercase English letters (a-z), the original word.
Output
Print the resulting word after applying the method to the original word times.