题目
题目描述
给定若干个长度 ≤ 1 0 6 \le 10^6 ≤106的字符串,询问每个字符串最多是由多少个相同的子字符串重复连接而成的。如:ababab 则最多有 3 个 ab 连接而成。
输入格式
输入若干行,每行有一个字符串。特别的,字符串可能为 . 即一个半角句号,此时输入结束。
样例
样例输入
abcd
aaaa
ababab
.
样例输出
1
4
3
代码详解
哈希
ACcode
#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
const int M=1e7+7;
char s[M];
ull l;
ull b=1311;
ull h[M];
inline ull ksm(ull);
inline void H();
inline ull H_p(ull,ull);
inline bool check(ull,ull);
int main()
{
scanf("%s",s+1);
while(s[1]!='.'){
l=strlen(s+1);
H();
for(ull i=1;i