#312. 字符串前缀查找

    ID: 312 Type: Default 1000ms 256MiB Tried: 0 Accepted: 0 Difficulty: (None) Uploaded By: Tags>codingbatString-2gesp6DFSBFS

字符串前缀查找

Prefix String Search

Background

Congcong has been studying string properties recently. He finds many interesting patterns hidden within strings.

Problem Description

Given a string ss and an integer NN, consider the prefix string made of the first NN characters of ss. Determine if this prefix string appears somewhere else in the original string ss (i.e., not starting at index 00). Assume that the string ss is not empty and that NN is in the range 1Ns1 \le N \le |s|.

Input Format

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

Output is printed to standard output in the following format.

Output true if the prefix string appears elsewhere; otherwise, output false.

Sample

abXYabc
1
true
abXYabc
2
true
abXYabc
3
false

Sample Explanation

For the first sample, the string is "abXYabc" and N=1N=1. The prefix string is "a". It appears again in the original string starting at index 55, so the output is true. For the second sample, the string is "abXYabc" and N=2N=2. The prefix string is "ab". It appears again in the original string starting at index 55, so the output is true. For the third sample, the string is "abXYabc" and N=3N=3. The prefix string is "abX". It does not appear anywhere else in the original string besides starting at index 00, so the output is false.

Constraints

Time limit: 11 second, Memory limit: 10241024 KiB for each test case.