Description

While Mike was walking in the subway, all the stuff in his back-bag dropped on the ground. There were several fax messages among them. He concatenated these strings in some order and now he has string s.

He is not sure if this is his own back-bag or someone else's. He remembered that there were exactly k messages in his own bag, each was a palindrome string and all those strings had the same length.

He asked you to help him and tell him if he has worn his own back-bag. Check if the given string s is a concatenation of k palindromes of the same length.

Input

The first line of input contains string s containing lowercase English letters (1 ≤ |s| ≤ 1000).

The second line contains integer k (1 ≤ k ≤ 1000).

Output

Print "YES"(without quotes) if he has worn his own back-bag or "NO"(without quotes) otherwise.

Examples
input
saba
2
output
NO
input
saddastavvat
2
output
YES
首先长度不能整除的当然不符合要求。
然后我们按照要求分割字符串,判断是不是回文串就好了
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int main()
{
string s;
int n;
cin>>s;
cin>>n;
if(s.length()%n)
{
cout<<"NO"<<endl;
}
else
{
int i,j;
int mid=s.length()/n;
for(i=0;i<n;i++)
{
string ss=s.substr(i*mid,mid);
for(int j=0;j<=ss.length()/2;j++)
{
if(ss[j]!=ss[ss.length()-1-j])
{
cout<<"NO"<<endl;
return 0;
}
}
// cout<<ss<<endl;
}
cout<<"YES"<<endl; } return 0;
}

  

 

Codeforces Round #305 (Div. 2) A的更多相关文章

  1. set+线段树 Codeforces Round #305 (Div. 2) D. Mike and Feet

    题目传送门 /* 题意:对于长度为x的子序列,每个序列存放为最小值,输出长度为x的子序列的最大值 set+线段树:线段树每个结点存放长度为rt的最大值,更新:先升序排序,逐个添加到set中 查找左右相 ...

  2. 数论/暴力 Codeforces Round #305 (Div. 2) C. Mike and Frog

    题目传送门 /* 数论/暴力:找出第一次到a1,a2的次数,再找到完整周期p1,p2,然后以2*m为范围 t1,t2为各自起点开始“赛跑”,谁落后谁加一个周期,等到t1 == t2结束 详细解释:ht ...

  3. 暴力 Codeforces Round #305 (Div. 2) B. Mike and Fun

    题目传送门 /* 暴力:每次更新该行的num[],然后暴力找出最优解就可以了:) */ #include <cstdio> #include <cstring> #includ ...

  4. 字符串处理 Codeforces Round #305 (Div. 2) A. Mike and Fax

    题目传送门 /* 字符串处理:回文串是串联的,一个一个判断 */ #include <cstdio> #include <cstring> #include <iostr ...

  5. Codeforces Round #305 (Div. 2) B. Mike and Fun 暴力

     B. Mike and Fun Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/548/pro ...

  6. Codeforces Round# 305 (Div 1)

    [Codeforces 547A] #include <bits/stdc++.h> #define maxn 1000010 using namespace std; typedef l ...

  7. Codeforces Round #305 (Div. 2) A. Mike and Fax 暴力回文串

     A. Mike and Fax Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/548/pro ...

  8. Codeforces Round #305 (Div. 1) B. Mike and Feet 单调栈

    B. Mike and Feet Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/547/pro ...

  9. Codeforces Round #305 (Div. 1) A. Mike and Frog 暴力

     A. Mike and Frog Time Limit: 20 Sec  Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/547/pr ...

  10. 「日常训练」Mike and Feet(Codeforces Round #305 Div. 2 D)

    题意 (Codeforces 548D) 对一个有$n$个数的数列,我们要求其连续$x(1\le x\le n)$(对于每个$x$,这样的连续group有若干个)的最小数的最大值. 分析 这是一道用了 ...

随机推荐

  1. js闭包(二)

    一.何谓“闭包”? 所谓“闭包(Closure)”,指的是一个拥有许多变量和绑定了这些变量的环境的表达式(通常是一个函数),因而这些变量也是该表达式的一部分. 描述的如此学术的官方解释,相信很少人能够 ...

  2. 算法Sedgewick第四版-第1章基础-004一封装交易对象

    1. package ADT; /****************************************************************************** * Co ...

  3. linux文件夹删除、创建

    一.删除文件夹 rm -rf ./html2imag 二.创建文件夹 mkdir html2image

  4. MySQL介绍与安装

    mysql介绍 #mysql就是一个基于socket编写的C/S架构的软件 #客户端软件 mysql自带:如mysql命令,mysqldump命令等 python模块:如pymysql 数据库管理软件 ...

  5. Person.delete请求----强大的bug---下班之前总结整个过程

    默认访问的是: findAll(query) 还有个findAll(ids,query) 只有findAll才调用了findEntity->findById: 那么我重写了findById,查询 ...

  6. 浅谈assert()函数的用法

    #include<stdio.h> #include<assert.h> char * Strcpy(char *dst,const char *src) { assert(d ...

  7. UVa 766 Sum of powers (伯努利数)

    题意: 求 ,要求M尽量小. 析:这其实就是一个伯努利数,伯努利数公式如下: 伯努利数满足条件B0 = 1,并且 也有 几乎就是本题,然后只要把 n 换成 n-1,然后后面就一样了,然后最后再加上一个 ...

  8. C#找到目录和其子目录的某个文件

    string url = ""; string[] urls = Directory.GetFiles(目录, 文件名, SearchOption.AllDirectories); ...

  9. WebAPI 请求跨域问题

    本人采用的是利用CORS解决跨越问题. 首先利用Nuget 安装“microsoft.aspnet.webapi.cors”,如下图所示: 紧接着,在WebApiConfig文件中加入 config. ...

  10. 【C# MVC】

    http://www.cnblogs.com/powertoolsteam/p/MVC_three.html