Advertisement
Guest User

Untitled

a guest
Oct 30th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. #include <iostream>
  2. #include <algorithm>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. string normal, rotated;
  10. int rotations=0;
  11. cin >> normal >> rotated;
  12. while(normal != rotated && rotations <10000)
  13. {
  14. std::rotate(normal.rbegin(), normal.rbegin() + 1, normal.rend());
  15. rotations++;
  16. }
  17. if(rotations==10000) cout << -1;
  18. else cout << rotations;
  19. return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement