题目
A character string is said to have period k if it can be formed by concatenating one or more repetitions
of another string of length k. For example, the string ”abcabcabcabc” has period 3, since it is formed
by 4 repetitions of the string ”abc”. It also has periods 6 (two repetitions of ”abcabc”) and 12 (one
repetition of ”abcabcabcabc”).
Write a program to read a character string and determine its smallest period.
Input
The first line oif the input file will contain a single integer N 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 80 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.

该程序旨在读取一个字符字符串并确定其最小周期。输入包含一个整数N表示测试用例数量,每个测试用例是一条最多80个非空字符的字符串。输出是输入字符串的最小周期。对于示例输入'HoHoHo',输出为2,因为可以由'Ho'重复构成。
最低0.47元/天 解锁文章
916

被折叠的 条评论
为什么被折叠?



