fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <algorithm>
  4. #include <stack>
  5. #include <queue>
  6. #include <string>
  7. #include <map>
  8. #include <cstring>
  9. #include <vector>
  10. #define MAX 100005
  11. using namespace std;
  12.  
  13. int main()
  14. {
  15. string s;
  16. cin >> s;
  17. int k;
  18. cin >> k;
  19. int l = s.size();
  20. bool flag = false;
  21. if(l % k == 1 || k > l)
  22. cout << "NO";
  23. else{
  24. int step = k, d = l / k;
  25. int pos = 0;
  26. for(int i = 1; i <= step; i++){
  27. for(int j = pos, v = d + pos - 1; j < d + pos - 1; j++, v--){
  28.  
  29. if(s[j] != s[v]){
  30. cout << "NO";
  31. return 0;
  32. }
  33. }
  34. pos += d;
  35. }
  36. cout << "YES";
  37. }
  38. return 0;
  39. }
Success #stdin #stdout 0s 2732KB
stdin
Standard input is empty
stdout
NO