UVA455「Periodic Strings」
1. 题目
题目链接:UVA455「Periodic Strings」 。
Description
A character string is said to have period if it can be formed by concatenating one or more repetitions of another string of length . For example, the string abcabcabcabc
has period , since it is formed by repetitions of the string abc
. It also has periods (two repetitions of abcabc
) and (one repetition of abcabcabcabc
).
Write a program to read a character string and determine its smallest period.
Input
The first line of the input file will contain a single integer indicating how many test case that your program will test followed by a blank line. Each test case will contain a single character string of up to non-blank characters. Two consecutive input will separated by a blank line.
Output
An integer denoting the smallest period of the input string for each input. Two consecutive output are separated by a blank line.
Sample Input
1 | 1 |
Sample Output
1 | 2 |
2. 题解
分析
字符串前缀函数的应用水题,结束。
代码
1 |
|