HDU 2594 Simpsons’ Hidden Talents(辛普森一家的潜在天赋) Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) [Description] [题目描述] Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had. Marge:…
Simpsons’ Hidden Talents Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 6888    Accepted Submission(s): 2461 Problem Description Homer: Marge, I just figured out a way to discover some of the…
Simpsons’ Hidden Talents Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4683    Accepted Submission(s): 1702 Problem Description Homer: Marge, I just figured out a way to discover some of the t…
Simpsons’ Hidden Talents Problem Description Write a program that, when given strings s1 and s2, finds the longest prefix of s1 that is a suffix of s2. Sample Input clinton homer riemann marjorie   Sample Output 0 rie 3   思路:要求的是s1的最长前缀是s2的后缀:那么kmp中的…
Simpsons’ Hidden Talents Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 4543    Accepted Submission(s): 1648 Problem Description Homer: Marge, I just figured out a way to discover some of the t…
Problem Description Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware we had.Marge: Yeah, what is it?Homer: Take me for example. I want to find out if I have a talent in politics, OK?Marge: OK.Homer: So I take so…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2594 这题直接用KMP算法就能够做出来,只是我还尝试了用扩展的kmp,这题用扩展的KMP效率没那么高. KMP算法: #include<stdio.h> #include<iostream> #include<string.h> using namespace std; int next[50001]; char p[50000],s[50000]; void getnex…
题目链接:http://acm.acmcoder.com/showproblem.php?pid=2594 题意:求最长的串 同一时候是s1的前缀又是s2的后缀.输出子串和长度. 思路:kmp 代码: #include <vector> #include <string> #include <algorithm> #include <iostream> #include <stdio.h> #include <string.h> us…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2594 题目大意:给两串字符串s1,s2,,找到最长子串满足既是s1的前缀又是s2的后缀,输出子串,及相应长度. 解题思路:这题是不是跟POJ 2752很像,没错,我们只要将s1.s2合并,不断递归直到找到长度小于等于s1.s2的公共前后缀即可. 代码 #include<iostream> #include<cstdio> #include<string> #include&…
Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 10513    Accepted Submission(s): 3671 Problem Description Homer: Marge, I just figured out a way to discover some of the talents we weren’t aware…