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;
}

全部评论

相关推荐

2025-11-10 21:00
门头沟学院 Java
程序员牛肉:没啥必要了,3月末就开暑期实习了,你现在找还不一定能找到。看你啥学历了。 双非基本代表想进好公司无望了。211的话,现在继续沉淀,零日常实习参加暑期其实也压力不太大
点赞 评论 收藏
分享
2025-12-15 12:50
河北工程大学
sta666:我也是这个国际商业化的,三天,一天一面,就通过了,不过我是后端实习生,好好面感觉能过。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务