#310. 字符串递减截取拼接

    ID: 310 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatString-2gesp3字符串循环结构

字符串递减截取拼接

String Decreasing Substring Concatenation

Background

Congcong is currently learning about string processing. He encountered an interesting problem and needs your help to solve it.

Problem Description

Given a string ss and an integer nn, return a new string. This new string is formed by concatenating the first nn characters of ss, followed by the first n−1n-1 characters of ss, then the first n−2n-2 characters of ss, and so on, until the first 11 character of ss. You may assume that nn is between 00 and the length of the string ss, inclusive (i.e., 0≤n≤extlength(s)0 \le n \le ext{length}(s)).

Input Format

Input is given from standard input in the following format.

A line containing a string ss. A line containing an integer nn.

Output Format

Output is printed to standard output in the following format.

A string, representing the concatenated result.

Sample

Chocolate
4
ChocChoChC
Chocolate
3
ChoChC
Ice Cream
2
IcI

Sample Explanation

Sample 1: The input string is "Chocolate\