1 /* 2 字符串处理:回文串是串联的,一个一个判断 3 */ 4 #include <cstdio> 5 #include <cstring> 6 #include <iostream> 7 #include <algorithm> 8 #include <string> 9 using namespace std; 10 11 const int MAXN = 1e3 + 10; 12 const int INF = 0x3f3f3f3f; 13 char s[MAXN]; 14 15 bool check(int x, int y) 16 { 17 for (int i=x, j=y; i<j; ++i, --j) 18 { 19 if (s[i] != s[j]) return false; 20 } 21 22 return true; 23 } 24 25 int main(void) //Codeforces Round #305 (Div. 2) A. Mike and Fax 26 { 27 int k; 28 while (scanf ("%s", s) == 1) 29 { 30 scanf ("%d", &k); 31 int len = strlen (s); 32 if (len % k != 0) puts ("NO"); 33 else if (len == 1 && k == 1) puts ("YES"); 34 else 35 { 36 int m = len / k; bool flag = true; 37 for (int i=0; i<len; i+=m) 38 { 39 if (!check (i, i+m-1)) 40 { 41 flag = false; break; 42 } 43 } 44 if (flag) puts ("YES"); 45 else puts ("NO"); 46 } 47 } 48 49 return 0; 50 }