HDU 4763—Theme Section
来源:互联网 发布:java富有创意的小程序 编辑:程序博客网 时间:2024/06/03 19:27
http://acm.hdu.edu.cn/showproblem.php?pid=4763
直接上KMP的代码,过后会把EX_KMP 的方法写出来之后再补上代码。
#include <iostream>#include <string>#include <algorithm>#include <string.h>#define maxs 1000005using namespace std;int nexts[maxs],ex[maxs];char s[maxs];//Kmp /*void get_kmp(char *s,int nexts[]){ int i=0,len=strlen(s),k; k=nexts[0]=-1; while(i<len) { if(k==-1||s[i]==s[k]) nexts[++i]=++k; else k=nexts[k]; }}int deal(){ int i,j,len=strlen(s); for(i=nexts[len];i;i=nexts[i]) { for(j=2*i;j<len-i;j++) if(nexts[j]==i) return i; } return 0;}int main(){ int t; cin>>t; while(t--) { cin>>s; int len=strlen(s),tm=len; int ans=0; get_kmp(s,nexts); ans=deal(); cout<<ans<<endl; } return 0;}
0 0
- HDU 4763—Theme Section
- HDU 4763 Theme Section
- hdu 4763 Theme Section
- hdu 4763 Theme Section
- HDU-4763 Theme Section
- HDU 4763 Theme Section
- Hdu-4763 Theme Section
- hdu 4763 Theme Section
- hdu 4763 Theme Section
- HDU 4763Theme Section
- hdu 4763 Theme Section
- hdu 4763 Theme Section
- hdu 4763Theme Section
- hdu 4763——Theme Section
- KMP-hdu-4763-Theme Section
- hdu 4763 Theme Section (双哈希)
- hdu 4763 Theme Section(KMP)
- hdu 4763 Theme Section kmp
- word ladder
- word ladder
- 读『开发App常见的九大错误』
- 用DOS写一个简单的虚拟WIFI工具,CMD电脑无线WIFI工具,BAT实现WIFI和自动关机
- 语法分析的基本概念
- HDU 4763—Theme Section
- c++:友元函数
- 网络IO模型(同步异步,阻塞非阻塞)
- word ladder
- Android——登录界面、SharedPreferences实现记住密码等账户信息
- word ladder
- thinkphp整合系列之友盟消息推送
- C#-如何ping IP
- UVA1600 Dfs回溯完全遍历+记忆化搜索(用最小距离剪枝)+细节处理 (值得复习)(水)