果然 还是踩了老!!!,一不留神把nex定义成char了!!!!
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+7;
char b[maxn];
int nex[maxn];
int m;
void pre(){
nex[1]=0;
int i,j=0;
for(i=1;i<m;i++){
while(j>0&&b[i+1]!=b[j+1])
j=nex[j];
if(b[i+1]==b[j+1]) j++;
nex[i+1]=j;
}
}
int main(){
int i,id=0;
while(~scanf("%d",&m),m!=0){
scanf("%s",b+1);
pre();
printf("Test case #%d\n",++id);
for(i=2;i<=m;i++){//i是整个长度 ,(i-nex[i])是周期
if(i%(i-nex[i])==0&&i/(i-nex[i])>1){//循环节的长度要>1
printf("%d %d\n",i,i/(i-nex[i]));
}
}
puts("");
}
}