#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
char a[1000+100];
bool judge(int m,int n) {
for(int i=m;i<=(m+n)/2;i++)
if(a[i]!=a[m+n-i]) return 0;
return 1;
}
int main() {
int k;
while(~scanf("%s",a)) {
scanf("%d",&k);
int len=strlen(a);
if(len%k) { printf("NO\n"); continue; }
int flag=0;
int i;
for(i=0;i<len;i+=len/k)
if(judge(i,i+len/k-1)==0) { printf("NO\n"); flag=1; break; }
if(!flag) printf("YES\n");
}
return 0;
}
Codeforces Round #305 (Div. 2), problem: (A) Mike and Fax
于 2015-05-28 20:30:34 首次发布