#include <bits/stdc++.h>
using namespace std;
int n;
int t;
int ct=0;
int ne[2000100];
void sol(){
printf("Test case #%d\n",++ct);
char str[n+1];
cin>>str+1;
ne[1] = 0;
for(int i=2,j=0;i<=n;i++){
while(j && str[i] != str[j+1]) j = ne[j];
if(str[i] == str[j+1]) j++;
ne[i] = j;
}
for(int i=1;i<=n;i++){
int t = i - ne[i];
if(i % t == 0 && i/t > 1){
printf("%d %d\n",i,i/t);
}
}
puts("");
}
int main(){
while(1){
cin>>n;
if(n == 0) return 0;
else sol();
}
}
acw.141 周期 (kmp
最新推荐文章于 2024-07-12 17:06:20 发布