亲和串
来源:互联网 发布:君子知怕的论证过程 编辑:程序博客网 时间:2024/06/06 12:52
http://acm.hdu.edu.cn/showproblem.php?pid=2203
#include<iostream>
#include<cstring>
using namespace std;
char s1[100010],s2[100010],c[200010],next1[100010];
void getnext(char *s2,int len2)
{
int i=0,j=-1;
next1[0]=-1;
while(i<len2)
{
if(j==-1 || s2[i]==s2[j])
{
i++;
j++;
next1[i]=j;
}
else
j=next1[j];
}
}
int main()
{//freopen("C:\\Users\\John\\Desktop\\hi.txt","r",stdin);
int i,j,ok;
while(cin>>s1>>s2)
{
memset(c,0,sizeof(c));
ok=0;
strcat(c,s1);
strcat(c,s1);
int len1=strlen(c);
int len2=strlen(s2);
if(len1<len2)
{
cout<<"no"<<endl;
continue;
}
getnext(s2,len2);
for(i=0,j=0;i<len1;)
{
if(j==-1 || c[i]==s2[j])
i++,j++;
else
j=next1[j];
if(j==len2)
{
ok=1;
break;
}
}
if(ok==1)
cout<<"yes"<<endl;
else
cout<<"no\n";
}
return 0;
}
- 亲和串
- 亲和串
- 亲和串
- 亲和串
- 亲和串
- 亲和串
- 亲和串
- 亲和串
- 亲和串
- 亲和串
- 亲和串
- hud_ACM_2203_亲和串
- HDU 2203 亲和串
- hdu2203 亲和串
- HDU 2203 亲和串
- HDU - 2203 亲和串
- hdu 2203 亲和串
- HDU2203:亲和串
- GRE写作必备句型
- import caffe时出错:can not find module skimage.io
- [深入学习C#]C#实现多线程的方式:Task——任务
- Mac 批量删除 .svn 文件
- LeetCode-Min Stack-解题报告
- 亲和串
- Java——集合工具类和jdk1.5有关集合的新特性
- 如何在spring官网上下载source code
- 算法思路
- 斯坦福《机器学习》Lesson4感想--1、Logistic回归中的牛顿方法
- ORA-00600 [3020] ORA-10560问题处理
- 【转】XmlDocument类
- 输入一个整数数组,判断该数组是不是某个二叉搜索树的前序遍历结果
- 网站设计知识论