Skip to content

Instantly share code, notes, and snippets.

@oskimura
Created July 22, 2016 08:08
Show Gist options
  • Save oskimura/7a53202d30be7abb65e834cbbbb58495 to your computer and use it in GitHub Desktop.
Save oskimura/7a53202d30be7abb65e834cbbbb58495 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <string>
#include <iostream>
using namespace std;
int main()
{
string s;
string p;
// scanf("%s\n",&s);
//scanf("%s\n",&p);
cin >> s;
cin >> p;
int len = s.size();
for (int i=0;i<len;i++) {
bool flag = true;
for (int j=0; j<p.size() ;j++) {
if (s[(i+j)%len] != p[j]) {
flag = false;
}
}
if (flag) {
printf("Yes\n");
return 0;
}
}
printf("No\n");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment