随笔分类 - 字符串处理——kmp
摘要:题意:给定字符串S,A,B。现在让你对S进行切割,使得每个切割出来的部分在[A,B]范围内,问方案数。 思路:有方程,dp[i]=Σ dp[j] (S[j+1,i]在合法范围内)。 假设M和N的最长公共前缀为长度是LCP,那么字符串M>=字符串N的条件是 LCP=|N|或者(LCP<|N|&&M[l
阅读全文
摘要:不知道写什么。。。
阅读全文
摘要:Sample Input Sample Output 给定一个数字字符串S,如果一个数字字符串(只包含0-9,可以有前导0)中出现且只出现1次S,我们就称这个字符串是好的。 例如假设S=666,则1666、03660666是好的,6666、66、123不是好的;假设S=1212,则01212、121
阅读全文
摘要:题目描述 一个串T是S的循环节,当且仅当存在正整数k,使得S是T k Tk (即T重复k次)的前缀,比如abcd是abcdabcdab的循环节。给定一个长度为n的仅由小写字符构成的字符串S,请对于每个k(1<=k<=n),求出S长度为k的前缀的最短循环节的长度per i peri 。字符串大师小Q觉
阅读全文
摘要:One day Silence is interested in revolving the digits of a positive integer. In the revolving operation, he can put several last digits to the front o
阅读全文
摘要:After the war, the supersonic rocket became the most common public transportation. Each supersonic rocket consists of two "engines". Each engine is a
阅读全文
摘要:我们定义2个字符串的相似度等于两个串的相同前缀的长度。例如 "abc" 同 "abd" 的相似度为2,"aaa" 同 "aaab" 的相似度为3。 给出一个字符串S,计算S同他所有后缀的相似度之和。例如:S = "ababaa",所有后缀为: ababaa 6 babaa 0 abaa 3 baa
阅读全文
摘要:先放代码。 下标从1开始。 #include<cstdio> #include<iostream> #include<cstring> using namespace std; const int N = 101010; int next[N],extand[N]; char S[N],T[N];
阅读全文
摘要:描述 给定两个字符串A和B,请你求出字符串A最少重复几次才能使得B是A的子串。 例如A="hiho",B="hohihohi"。则A重复3次之后变为"hihohihohiho",这时B是A的子串。 输入 输入包含多组数据。 第一行包含一个整数T,表示数据组数。 (1 ≤ T ≤ 5) 对于每组数据,
阅读全文
摘要:Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concate
阅读全文
摘要:Beside other services, ACM helps companies to clearly state their “corporate identity”, which includes company logo but also other signs, like tradema
阅读全文
摘要:Given two strings a and b we define a*b to be their concatenation. For example, if a = "abc" and b = "def" then a*b = "abcdef". If we think of concate
阅读全文
摘要:Time limit per test: 1.0 seconds Memory limit: 256 megabytes Time limit per test: 1.0 seconds Memory limit: 256 megabytes Time limit per test: 1.0 sec
阅读全文
摘要:It is well known that AekdyCoin is good at string problems as well as number theory problems. When given a string s, we can write down all the non-emp
阅读全文
摘要:是本来想今天写下后缀数组,谁知明天要交高数作业,还有大物视频,英语视频blablabla。。。 赶啊。。。。然后忍不住写了两个kmp水题 每天都要进步
阅读全文
摘要:求a串中有多少个b串,可重复使用。 KMP:
阅读全文