来源:
power strings
time limit: 3000ms
memory limit: 65536k
total submissions: 30293
accepted: 12631
description
given two strings a and b we define a*b to be their concatenation. for example, if a = "abc" and b = "def" then a*b = "abcdef". if we think of concatenation as multiplication, exponentiation by a non-negative integer is defined in the normal way: a^0 = "" (the
empty string) and a^(n+1) = a*(a^n).
input
each test case is a line of input representing s, a string of printable characters. the length of s will be at least 1 and will not exceed 1 million characters. a line containing a period follows the last test case.
output
for each s you should print the largest n such that s = a^n for some string a.
sample input
sample output
hint
this problem has huge input, use scanf instead of cin to avoid time limit exceed.
source
题意:不多解释
这题书上说是用kmp来做,自己开始也尝试这样做,但后来发现根本就没有这个必要~~~几个简单的字符串处理函数就可以a掉了
代码: