Polycarp loves ciphers. He has invented his own cipher called repeating.
Repeating cipher is used for strings. To encrypt the string s=s1s2…sms=s1s2…sm (1≤m≤101≤m≤10), Polycarp uses the following algorithm:
-
he writes down s1s1 ones,
-
he writes down s2s2 twice,
-
-
...
-
he writes down smsm mm times.
For example, if ss="bab" the process is: "b" →→ "baa" →→ "baabbb". So the encrypted ss="bab" is "baabbb".
Given string tt — the result of encryption of some string ss. Your task is to decrypt it, i. e. find the string ss.
Input
The first line contains integer nn (1≤n≤551≤n≤55) — the length of the encrypted string. The second line of the input contains tt — the result of encryption of some string ss. It contains only lowercase Latin letters. The length of tt is exactly nn.
It is guaranteed that the answer to the test exists.
Output
Print such string ss that after encryption it equals tt.
Examples
input
6
baabbb
output
bab
input
10
ooopppssss
output
oops
input
1
z
output
z
题目描述:
密码加密方式是位置n上的字母重复写n次,比如ab加密后是abb.
现在要解密。
分析:
计算数字下标即可,每次加n。
代码:
#include<stdio.h> #include<math.h> #include<iostream> #include<queue> #define MIN(x,y) x<y?x:y; using namespace std; int main() { int n; cin>>n; char a[n+6]; getchar(); for(int i=0;i<n;i++) { a[i]=getchar(); } for(int i=0,k=1;i<n;i+=k,k++) { printf("%c",a[i]); } return 0; }