ITP1_8_D: Ring


リング状になってる文字列の一部に検索したい文字列があるか判定する問題。


#include <iostream>
#include <vector>
#include <string>
#include <stdio.h>

using namespace std;
string str,str2,str3;
int main() {
// your code goes here
std::cin>>str>>str3;
str2=str+str;
bool hit=false;
for(int i=0;i<str.size();i++){
	if(str3==str2.substr(i,str3.size())){
		hit=true;
		break;
	}
}
printf("%s\n",hit?"Yes":"No");
return 0;
}
最終更新:2016年03月22日 09:54