您的位置:首页 > 其它

HDU 2203 亲和串 (想法题,字符串处理)

2014-06-18 17:55 316 查看
给定两个字符串s1和s2,如果能通过s1循环移位,使s2包含在s1中,那么我们就说s2 是s1的亲和串。S1+S1后进行查找即可

#include<iostream>
#include<sstream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;

int main()
{
string s1,s2;
while(cin>>s1)
{
cin>>s2;
s1=s1+s1;
int ans=s1.find(s2);
if(ans!=-1) cout<<"yes"<<endl;
else cout<<"no"<<endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: