프로그램 명: coci_slom
제한시간: 1 초
창현이는 문자열을 암호화하는 알고리즘을 개발하였다. 그의 알고리즘은 길이가 K인 문자열의 위치를 아래 방식으로 바꾼다. (단, K가 홀수이면 p=(K+1)/2, K가 짝수이면 p=K/2)
- 1, 2, …, p번째 문자를 각각 1, 3, …, p*2-1번째로 옮긴다.
- p+1, …, K번째 문자는 각각 (K-p)*2, …, 2번째로 옮긴다.
창현이는 조금 더 안전한 암호화를 위해 문자열을 X번 변형하기로 했다. X와 창현이의 암호가 주어질 때 원래 문자열을 구하는 프로그램을 작성하여라.
입력 형식
-
첫 번째 줄에는 변형 횟수 X가 주어진다. (1 ≤ X ≤ 1,000,000,000)
-
두 번째 줄에는 X번 변형한 후의 문자열이 주어진다. 문자열의 길이는 3 이상 1,000 이하이다.
전체 데이터의 50%는 X ≤ 100 이다.
출력 형식
X번 변형하기 전의 문자열을 출력한다.
입출력 예
입력 예 1
출력 예 1
4
acefdb
abcdef
입력 예 2
출력 예 2
1000
aaaaaa
aaaaaa
입력 예 3
출력 예 3
11
srama
sarma
입력 예 1 설명
abcdef를 4번 변형하면 순서대로 afbecd, adfcbe, aedbfc, acefdb가 된다.
Little Marin spent all his day generating test data for COCI. He simply couldn't make it work, so he had
a nervous breakdown and can't even see clearly anymore. Every time he blinks while reading, the letters
in a word get mixed up so that the letters from the second half of the word (the shorter half, if the
length is an odd number) "jump in" between the letters from the first half in the following way:
- the last letter "jumps in" between the first and the second letter
- the penultimate letter "jumps in" between the second and the third letter
- the k th letter from the end "jumps in" between the k th and the (k+1) th letter from the beginning
For example, the word "abcdef" would become "afbecd" after blinking.
If Marin blinks again, the same thing happens. After two blinks, the word "abcdef" becomes "adfcbe".
Marin has decided to write a program to help him determine what's exactly written on the screen.
Unfortunately, after a day's work, he's simply too tired and he needs your help. You are given X, the
number of blinks, and the word Marin sees on the screen. Write a program to solve the mystery for
Marin and determine what was actually the word before he blinked X times.
INPUT
-
The first line of input contains a positive integer X (1 ≤ X ≤ 1 000 000 000), the number of times
Marin blinked.
-
The second line of input contains the word from the screen, its length being from the interval [3, 1000].
The word will consist only from small letters of English alphabet.
OUTPUT
The first and only line of output must contain the original word, before Marin blinked X times.
SAMPLE TESTS
input
4
acefdb
output
abcdef
input
1000
aaaaaa
output
aaaaaa
input
11
srama
output
sarma
Clarification of the first example: The word gets altered in the following order: abcdef, afbecd,
adfcbe, aedbfc, acefdb.
출처:coci/2013-2014/contest2 3번
[질/답]
[제출 현황]
[푼 후(0)]