-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolution.cc
46 lines (40 loc) · 923 Bytes
/
Solution.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#define __STDC_FORMAT_MACROS
#include <inttypes.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define VAR(V,init) __typeof(init) V=(init)
#define FOREACH(I,C) for(VAR(I,(C).begin());I!=(C).end();I++)
#define MAXLEN 1010
int main(int argc, char *argv[]) {
char s[MAXLEN];
int k;
scanf("%s %d", s, &k);
int len = strlen(s);
if (len % k != 0) {
printf("NO\n");
return 0;
}
int chunkLen = len / k;
for (int i=0; i < len; i += chunkLen) {
int start = i;
int end = start + chunkLen - 1;
while (start < end) {
if (s[start++] != s[end--]) {
printf("NO\n");
return 0;
}
}
}
printf("YES\n");
return 0;
}