题目链接 题意:求n个串的公共子串 思路:由于数据比较小,所以可以暴力枚举第一个串的所有子串,进行kmp匹配。 #include<bits/stdc++.h> using namespace std; typedef long long ll; char ans[100]; int Next[100 Read More
posted @ 2020-09-10 12:44 Ldler Views(89) Comments(0) Diggs(0) Edit
题目链接 题意:求字符串的前缀能否构成一个周期字符串,并输出周期次数。 思路:根据kmp算法next数组的性质为最长公共前后缀可知,设L为字符串的前缀长度,则有L(i)%(L(i)-next(i))==0则说明这个前缀为周期字符串,且次数为L(i)/(L(i)-next(i))。同时判断次数不为1。 Read More
posted @ 2020-09-10 10:56 Ldler Views(126) Comments(0) Diggs(0) Edit