萌新刚学OI,感觉写的没问题,可能是被毒瘤输出格式搞WA了,求助!
查看原帖
萌新刚学OI,感觉写的没问题,可能是被毒瘤输出格式搞WA了,求助!
726138
fengjinyonghu楼主2022/6/27 10:55
#include<bits/stdc++.h>
using namespace std;
int n,nex[1000005],t,t2;
char s[1000005];
int main()
{
	cin>>t;
	while(t--)
	{
		t2++;
		cin>>n;
		cin>>s+1;
		int j=0;
		cout<<"Test case #"<<t2<<endl;
		for(int i=2;i<=n;i++)
		{
			if(j&&s[i]!=s[j+1]) j=nex[j];
			if(s[i]==s[j+1]) j++;
			nex[i]=j;
		}
		for(int i=2;i<=n;i++)
		{
			if(i%(i-nex[i])==0&&nex[i])
			{
				cout<<i<<' '<<i/(i-nex[i])<<endl;
			}
		}
		cout<<endl;
	}
	return 0;
}

求助

2022/6/27 10:55
加载中...