#P2477. Power Strings

Power Strings

题目来源

POJ 2406

题目描述

Given two strings a and b we define aba*b to be their concatenation. For example, if a="abc"a = "abc" and b="def"b = "def" then ab="abcdef"a*b = "abcdef". If we think of concatenation as multiplication, exponentiation by a non-negative integer is defined in the normal way: a0=""a^0 = "" (the empty string) and an+1=a(an)a^{n+1} = a*(a^n).

输入格式

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.

输出格式

For each s you should print the largest nn such that s=ans = a^n for some string aa.

样例

abcd
aaaa
ababab
1
4
3

提示

This problem has huge input, use scanf instead of cin to avoid time limit exceed.