Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
45919 xujindong 【模拟赛3】罪恶的PQA C++ 解答错误 83 1 MS 412 KB 511 2022-02-25 20:31:21

Tests(5/6):


#include <bits/stdc++.h> using namespace std; int n,nxt[1000005]; char s[1000005]; void KMP(int m,char *t) { nxt[1]=0; for(int i=2,j=0; i<=m; i++) { while(j>0 && t[i]!=t[j+1])j=nxt[j]; if(t[i]==t[j+1])j++; nxt[i]=j; } } int main() { while(cin>>s+1) { if(s[1]=='.')break; n=strlen(s+1); KMP(n,s); for(int i=n-1; i>=0; i--) { if(nxt[i]==0) { cout<<(n==1?1:(n/(i)))<<'\n'; break; } } } return 0; }


测评信息: