constint max = 10000001; char Str[max]; int next[max]; voidget_next(int len){ int i = 0, j = -1; next[0] = -1; while(i < len) { if (j == -1 || Str[i] == Str[j]) { ++i; ++j; next[i] = j; } else j = next[j]; } return; }
intmain(){ while (scanf("%s", Str) && Str[0] != '.') { int len = strlen(Str); get_next(len); int num = len-next[len]; if (len%(num) == 0) printf("%d\n", len/(num)); elseprintf("1\n"); } return0; }