#C13478. Repeated Substring Pattern
Repeated Substring Pattern
Repeated Substring Pattern
Given a non-empty string s
, determine whether it can be constructed by taking a substring of it and appending multiple copies of the substring together. In other words, check if there exists a substring t such that s is equal to t repeated one or more times. For example, "abab" can be constructed by repeating "ab", while "aba" cannot.
The answer should be True
if such a substring exists, and False
otherwise.
Note: When using formulas in your explanation, ensure that they are formatted in LaTeX. For example, the condition can be written as \( n \mod i = 0 \) where \( n \) is the length of the string and \( i \) is the candidate substring length.
inputFormat
The input consists of a single line containing a non-empty string s
.
outputFormat
Output a single line: True
if the string can be constructed by repeating a substring, otherwise False
.
abab
True