KMP字符串匹配
RJ28
小学生
展开
-
LA-3026 Period(kmp应用)
题意:给定一个长度为n的字符串s,求它的每个前缀的最短循环节。即对于每个i(i>1),求一个最大的整数k>1,使得S的前i个字符组成的前缀是某个字符串重复K次得到。输出所 有存在K的i和对应的K。 分析:根据KMP中next数组的定义,当(i+1)%(i-next[i]) == 0时,其最短循环节即为(i-next[i]). #include #include #incl原创 2016-02-28 00:15:32 · 459 阅读 · 0 评论 -
Hdu-4763 Theme Section
Problem Description It's time for music! A lot of popular musicians are invited to join us in the music festival. Each of them will play one of their representative songs. To make the programs more i原创 2016-05-19 15:15:29 · 397 阅读 · 0 评论 -
Hdu-4749 Parade Show
Description 2013 is the 60 anniversary of Nanjing University of Science and Technology, and today happens to be the anniversary date. On this happy festival, school authority hopes that the原创 2016-05-19 11:07:36 · 416 阅读 · 0 评论 -
Hdu-3746 Cyclic Nacklace
Problem Description CC always becomes very depressed at the end of this month, he has checked his credit card yesterday, without any surprise, there are only 99.9 yuan left. he is too distressed and原创 2016-05-18 16:47:26 · 314 阅读 · 0 评论 -
BZOJ-3670: [Noi2014]动物园
Description 近日,园长发现动物园中好吃懒做的动物越来越多了。例如企鹅,只会卖萌向游客要吃的。为了整治动物园的不良风气,让动物们凭自己的真才实学向游客要吃的,园长决定开设算法班,让动物们学习算法。 某天,园长给动物们讲解KMP算法。 园长:“对于一个字符串S,它的长度为L。我们可以在O(L)的时间内,求出一个名为next的数组。有谁预习了next数组的含义吗?” 熊猫:“对于原创 2016-05-18 16:17:59 · 350 阅读 · 0 评论 -
Hdu-2087 剪花布条
Description 一块花布条,里面有些图案,另有一块直接可用的小饰条,里面也有一些图案。对于给定的花布条和小饰条,计算一下能从花布条中尽可能剪出几块小饰条来呢? Input 输入中含有一些数据,分别是成对出现的花布条和小饰条,其布条都是用可见ASCII字符表示的,可见的ASCII字符有多少个,布条的花纹也有多少种花样。花纹条和小饰条不会超过1000个原创 2016-05-17 19:35:20 · 372 阅读 · 0 评论 -
Hdu-1867 A + B for you again
A + B for you again Time Limit: 5000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6027 Accepted Submission(s): 1493 Problem Description Generally原创 2016-05-16 19:44:24 · 346 阅读 · 0 评论 -
Hdu-3336 Count the string(KMP + DP)
Count the string Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 7697 Accepted Submission(s): 3581 Problem Description It is well kn原创 2016-05-16 15:48:23 · 398 阅读 · 0 评论 -
Codeforces Round #246 (Div. 2) D. Prefixes and Suffixes
You have a string s = s1s2...s|s|, where |s| is the length of string s, and si its i-th character. Let's introduce several definitions: A substring s[i..j] (1 ≤ i ≤ j ≤ |s|) of string s i原创 2016-05-16 15:01:40 · 623 阅读 · 0 评论 -
Hdu-5763 Another Meaning(DP+KMP)
Another Meaning Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 558 Accepted Submission(s): 262 Problem Description As is known to a原创 2016-07-29 13:49:50 · 371 阅读 · 0 评论