#309. 字符串截取与重复

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

字符串截取与重复

String Repetition

Background

Congcong is currently studying string processing and has encountered an interesting problem that requires your help to solve.

Problem Description

Given a string and an integer nn, return a new string made of nn repetitions of the last nn characters of the original string. You may assume that nn is between 00 and the length of the string, inclusive.

Input Format

The input is given from standard input in the following format:

The first line contains a string SS. The second line contains an integer nn.

Output Format

The output should be printed to standard output in the following format:

The resulting string.

Sample

Hello
3
llollollo
Hello
2
lolo
Hello
1
o

Sample Explanation

  • Sample 1: The string is "Hello\