UVA-11192 - Group Reverse

  • UVa Online Judge 解題結果請於 Submit 後,參閱 uHunt
  • 如果你有任何建議與指教,歡迎於下方留言一起討論喔!
  • 本題選為「20161004 大學程式能力檢定 CPE」題目。

題意概要

本題為「分組反轉字串」,假設給定以下字串:“TOBENUMBERONEWEMEETAGAINANDAGAINUNDERBLUEICPCSKY” 該字串的長度為 ,如果將該字串分成 個長度為 的群組,再將每個群組內的字串分別做反轉,會得到以下另一個新的字串:“UNEBOTNOREBMEEMEWENIAGATAGADNAEDNUNIIEULBRYKSCPC” 本題將給定群組數目及字串,試求該字串的分組反轉字串。


Input

The input file contains at most lines of inputs. Each line contains at integer () which denotes the number of groups followed by a string whose length is a multiple of . The length of the string is not greater than . The string contains only alpha numerals. Input is terminated by a line containing a single zero.


Output

For each line of input produce one line of output which contains the group reversed string.


Sample Input

3 ABCEHSHSH
5 FA0ETASINAHGRI0NATWON0QA0NARI0
0

Sample Output

CBASHEHSH
ATE0AFGHANISTAN0IRAQ0NOW0IRAN0
profile-image
David Lu
Hello, I'm David Lu. I am a graduate student in Department of Computer Science at National Chiao Tung University, Taiwan. I am in the Networking and Sensing Systems (NSS) Lab at NCTU. If you have any question, please feel free to contact with me.
comments powered by Disqus