【ybtoj 高效进阶 2.1】 【字符串】 移位包含

【ybtoj 高效进阶 2.1】 【字符串】 移位包含

题目

在这里插入图片描述


解题思路

将原串弄成一个环
find一下判断是否包含


代码

#include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
string x,y;
int main()
{
    
    
	cin>>x>>y;
	x=x+x+x;
	if (x.find(y,0)!=-1)
	   printf("true\n");
	   else printf("false\n");
	return 0; 
}

猜你喜欢

转载自blog.csdn.net/qq_45621109/article/details/113030349