摘要:
Sample Inputclintonhomerriemannmarjorie Sample Output0rie 3输入两个字符串 ,求最长相同前后缀直接把两个字符串连接在一起求next就行了,唯一要注意的就是长度不能大于原来任一字符串的长度,如果长度大于了,要选择len1和len2中较小的一个输... 阅读全文
摘要:
Sample Input14abab Sample Output6输出包括从1到len长 字符串前缀的总个数abab:包括2个a,2个ab,1个aba,1个abab 1 # include 2 # include 3 using namespace std; 4 5 char S[20001... 阅读全文
摘要:
Sample Input3aaaabcaabcde Sample Output025题目大意:给你一个字符串,要求将字符串的全部字符最少循环2次需要添加的字符数。例子:abcabc 已经循环2次,添加数为0abcac 没有循环2次,添加字符abcac。数目为5.abcabcab 已经循环过2次,但第... 阅读全文
摘要:
给一个串,让你找一个子串,形如EAEBE,就是一个串在开头结尾中间各出现一次,问这个E最长是多少Sample Input5xyabcaaaaaaabaaaxoaaaaa Sample Output00112 1 # include 2 # include 3 using namespace... 阅读全文
摘要:
Sample Inputabcdaaaaababab.Sample Output1 //1个abcd4 //4个a3 //3个ab 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const ... 阅读全文
摘要:
Sample Input3aaa12aabaabaabaab0Sample OutputTest case #12 23 3Test case #22 2 //aa有2个a6 2 //aabaab有2个aab9 312 40 1 2 3 4 5 6 7 8 9 10 11a a b a ... 阅读全文
摘要:
求模式串在主串中出现的次数Sample Input3BAPCBAPCAZAAZAZAZAVERDIAVERDXIVYERDIANSample Output130 1 #include 2 #include 3 using namespace std; 4 5 const int N = 100... 阅读全文
摘要:
Sample Input213 51 2 1 2 3 1 2 3 1 3 2 1 21 2 3 1 313 51 2 1 2 3 1 2 3 1 3 2 1 21 2 3 2 1 Sample Output6-1 1 # include 2 # include 3 # include 4 us... 阅读全文