A. Repeating Cipher

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 s3s3 three times,

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
inputCopy
6
baabbb
outputCopy
bab
inputCopy
10
ooopppssss
outputCopy
oops
inputCopy
1
z
outputCopy
z

#include <iostream>
#include <string>
using namespace std;

int main()
{
    int n;
    while(cin >> n)
    {
        string s;
        cin >> s;
        int num = 1;
        for(int i = 0; i < n; ++i)
        {
            cout << s[i];
            i += num;
            num++;
        }
        cout << '\n';
    }
    return 0;
}

全部评论

相关推荐

11-15 17:19
湖南大学 Java
成果成果成果果:这是哪个公司的hr,这么离谱吗,我没见过用性别卡技术岗的,身边女性同学拿大厂offer的比比皆是
点赞 评论 收藏
分享
11-06 10:58
已编辑
门头沟学院 嵌入式工程师
双非25想找富婆不想打工:哦,这该死的伦敦腔,我敢打赌,你简直是个天才,如果我有offer的话,我一定用offer狠狠的打在你的脸上
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务