hdu 3336【Count the string】(KMP)
摘要:一道字符串匹配的题目,仅仅借此题练习一下KMP因为这道题目就是要求用从头开始的n个字符串去匹配原来的字符串,很明显与KMP中求next的过程很相似,所以只要把能够从头开始匹配一定个数的字符串的个数加起来就OK了(再此结果上还应该加上字符串的长度,因为每个从头开始的字符串本身也可以去匹配自己的),即将next中值不为-1和0的个数统计出来即可。用GCC编译的,时间用了46MS。 1 #include 2 #include 3 #define MAXLEN 200005 4 #define MOD 10007 5 6 int next[MAXLEN]; 7 char myChar[MAXLE...
阅读全文
posted @
2013-09-26 23:28
Shirlies
阅读(329)
推荐(0) 编辑
UVa 401
摘要:A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA"is a palindrome because it is the same when the string is read from left to right as when the string is read from right to left.A mirrored string is a string for
阅读全文
posted @
2012-01-16 23:10
Shirlies
阅读(668)
推荐(0) 编辑