列表

详情


NC221563. MikawithEncryption

描述

Mika studied a new way to encrypt massages.

Given a string which length is even, Mika do the following process:

First Mika divides it into two parts from the middle. Then Mika writes the first part on the first line, the second part on the second line. Finally, Mika reads the string from the first column to the last column.

For example: There is a string called "". We divides it into two parts "" and ""
Then we write in the following way:


Finally, Mika reads it from the first column to the last column, which is "". That is the string Mika gets.

Now given you the string after encrypting, Willis wants to know the string before encrypting. Can you help him?

输入描述

A string after encrypting, which length is even and less than .
It is guaranteed that the string only consists upper or lower letters.

输出描述

Output one line which represents the string before encrypting.

示例1

输入:

GLouocdk

输出:

GoodLuck

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

C++(clang++11) 解法, 执行用时: 4ms, 内存消耗: 400K, 提交时间: 2021-05-08 12:36:08

#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int n=s.size();
	for(int i=0;i<n;i+=2)
	cout<<s[i];
	for(int i=1;i<n;i+=2)
	cout<<s[i];
}

Python3 解法, 执行用时: 40ms, 内存消耗: 7088K, 提交时间: 2021-09-10 14:59:03

a=input()
b=a[::2]+a[1::2]
print(b)

pypy3(pypy3.6.1) 解法, 执行用时: 48ms, 内存消耗: 18676K, 提交时间: 2021-05-08 12:34:01

s = input()
print(s[::2] + s[1::2])

上一题