v 0. Pasted by slipstak2 as cpp at 2015-01-23 05:34:54 MSK and set expiration to never.

Paste will expire never.

  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. int main() {
  9. #ifdef _DEBUG
  10.     freopen("input.txt", "r", stdin);
  11.     freopen("output.txt", "w", stdout);
  12. #endif
  13.     string buf, str;
  14.     cin>>buf;
  15.     cin>>str;
  16.     string initBuf = buf;
  17.     while (buf.size() < str.size()) {
  18.         buf += initBuf;
  19.     }
  20.  
  21.     buf = buf + buf;
  22.     bool isFind = buf.find(str) != -1;
  23.     if (!isFind) {
  24.         reverse(buf.begin(), buf.end());
  25.         isFind = buf.find(str) != -1;
  26.     }
  27.     cout<< (isFind ? "YES" : "NO") ;
  28.     return 0;
  29. }


Editing is locked.