You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
436 B
C++
18 lines
436 B
C++
#include <cstdio>
|
|
#include <cstring>
|
|
char str[1 << 20 | 1];
|
|
int next[1 << 20 | 1];
|
|
int len;
|
|
int main()
|
|
{
|
|
next[0] = -1;
|
|
while (scanf("%s", str))
|
|
{
|
|
if (str[0] == '.') break;
|
|
len = strlen(str);
|
|
for (int i = 0, j = -1; i < len;)
|
|
(~j && str[i] != str[j]) ? j = next[j] : next[++i] = ++j;
|
|
printf("%d\n", len % (len - next[len]) == 0 ? len / (len - next[len]) : 1);
|
|
}
|
|
return 0;
|
|
} |