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
abcd
aaaa
ababab
.
Sample Output
1
4
3
Hint
This problem has huge input, use scanf instead of cin to avoid time limit exceed.
题意: 给出一个字符串, 询问该串最多由几个循环串组成
思路:
我们可以发现当一个串由长度为i的子串循环组成时
1: rank[0] = rank[i] + 1
2: len % i == 0
3: heig[rak[0]] == len - i
对于第一点当前串如果是由该串循环组成, 则第一个字符开始的循环串一定与第i个字符开始的循环串排名相邻
所以 rank[0] = rank[i] + 1
对于第二点长度必定整除才行
第三点
显然第一个字符开始的循环串跟上一个排名的循环串的LCP = len - i
这个差值i即是循环串的长度
例如ababab
ababab与abab 的LCP = 4 = 6 - 2
PS:这题求SA使用倍增算法, 您将会得到

所以使用DC3吧, 不过这DC3我也看不懂, 也不会改(网上偷份拿着用吧), 下标从0开始输入的串可真是难受
//#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include