Codeforces Round #528 (Div. 2, based on Technocup 2019 Elimination Round 4) A - Right-Left Cipher

版权声明:欢迎转载,请注明此博客地址。 https://blog.csdn.net/Ever_glow/article/details/85273033

A. Right-Left Cipher

time limit per test

1 second

memory limit per test

256 megabytes

input

standard input

output

standard output

Polycarp loves ciphers. He has invented his own cipher called Right-Left.

Right-Left cipher is used for strings. To encrypt the string s=s1s2…sns=s1s2…sn Polycarp uses the following algorithm:

扫描二维码关注公众号,回复: 5928912 查看本文章
  • he writes down s1s1,
  • he appends the current word with s2s2 (i.e. writes down s2s2 to the right of the current result),
  • he prepends the current word with s3s3 (i.e. writes down s3s3 to the left of the current result),
  • he appends the current word with s4s4 (i.e. writes down s4s4 to the right of the current result),
  • he prepends the current word with s5s5 (i.e. writes down s5s5 to the left of the current result),
  • and so on for each position until the end of ss.

For example, if ss="techno" the process is: "t" →→ "te" →→ "cte" →→ "cteh" →→ "ncteh" →→ "ncteho". So the encrypted ss="techno" is "ncteho".

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 only 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 between 11 and 5050, inclusive.

Output

Print such string ss that after encryption it equals tt.

Examples

input

ncteho

output

techno

input

erfdcoeocs

output

codeforces

input

z

output

z

纪念第一次python过题。撒花。

代码实现:
 

str = input();
len = str.__len__();
now = 0;
t = "";
l = 0;r = len-1;
if len&1 == 0:
    while now < len:
        if now&1 == 1:
            t+=str[l];l+=1;
        else:
            t+=str[r];r-=1;
        now += 1;
else:
    while now < len:
        if(now&1 == 1):
            t+=str[r];r-=1;
        else:
            t+=str[l];l+=1;
        now += 1;
s = "";
i = 0;
while(i < len):
    s += t[len-1-i];
    i += 1;
print(s)

猜你喜欢

转载自blog.csdn.net/Ever_glow/article/details/85273033
今日推荐