Codeforces Round #305 (Div. 2) A
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.
The first line of input contains string s containing lowercase English letters (1 ≤ |s| ≤ 1000).
The second line contains integer k (1 ≤ k ≤ 1000).
Print "YES"(without quotes) if he has worn his own back-bag or "NO"(without quotes) otherwise.
saba
2
NO
saddastavvat
2
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的更多相关文章
- set+线段树 Codeforces Round #305 (Div. 2) D. Mike and Feet
题目传送门 /* 题意:对于长度为x的子序列,每个序列存放为最小值,输出长度为x的子序列的最大值 set+线段树:线段树每个结点存放长度为rt的最大值,更新:先升序排序,逐个添加到set中 查找左右相 ...
- 数论/暴力 Codeforces Round #305 (Div. 2) C. Mike and Frog
题目传送门 /* 数论/暴力:找出第一次到a1,a2的次数,再找到完整周期p1,p2,然后以2*m为范围 t1,t2为各自起点开始“赛跑”,谁落后谁加一个周期,等到t1 == t2结束 详细解释:ht ...
- 暴力 Codeforces Round #305 (Div. 2) B. Mike and Fun
题目传送门 /* 暴力:每次更新该行的num[],然后暴力找出最优解就可以了:) */ #include <cstdio> #include <cstring> #includ ...
- 字符串处理 Codeforces Round #305 (Div. 2) A. Mike and Fax
题目传送门 /* 字符串处理:回文串是串联的,一个一个判断 */ #include <cstdio> #include <cstring> #include <iostr ...
- 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 ...
- Codeforces Round# 305 (Div 1)
[Codeforces 547A] #include <bits/stdc++.h> #define maxn 1000010 using namespace std; typedef l ...
- 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 ...
- 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 ...
- 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 ...
- 「日常训练」Mike and Feet(Codeforces Round #305 Div. 2 D)
题意 (Codeforces 548D) 对一个有$n$个数的数列,我们要求其连续$x(1\le x\le n)$(对于每个$x$,这样的连续group有若干个)的最小数的最大值. 分析 这是一道用了 ...
随机推荐
- MongoDB数据导入hbase + 代码
需求: 从mongoDB里面查出来数据,判断是否有该列簇,如果有则导入此条数据+列簇,如果没有,则该条数据不包含该列簇 直接贴出代码: package Test; import java.util.A ...
- CheckBoxJS选中与反选得到Value
function XuanZe(val) { datastr = $("#hid_AID").val(); var newstr = ""; ...
- PHP trim() 函数
定义和用法 trim() 函数从字符串的两端删除空白字符和其他预定义字符. 语法 trim(string,charlist) 参数 描述 string 必需.规定要检查的字符串. charlist 可 ...
- c# 一维数组,二维数组,多维数组。
数组就是给一个变量定义多个字符,可以是string也可以是int.或者说是一组变量. 可以更加方便的操作大量数据. 数组的定义1.数组里面的内容必须是同一类型2.数据必须有长度限制 一维数组 *一.数 ...
- UITextField的文本框部分文本以*的方式来显示
#import "AppDelegate.h" @interface AppDelegate ()<UITextFieldDelegate>// 添加代理协议 @end ...
- [转]CSS块级元素和行内元素
原地址:http://www.studyofnet.com/news/398.html 本文导读:HTML中的元素可分为两种类型:块级元素和行级元素.这些元素的类型是通过文档类型定义(DTD)来指明. ...
- Linux kgdb命令
一.简介 kgdb是一种源码级的Linux内核调试器.使用kgdb调试内核时,需要结合gdb一起使用,使用他们可以对内核进行单步调试,设置断点,观察变量.寄存器的值等与应用调试相关的功能.然而也有其限 ...
- str() 和repr()的区别
>>> a='bbc' >>> a'bbc'>>> print abbc str()一般是将数值转成字符串:repr()是将一个对象转成字符串显示 ...
- Redhat 6 git服务器配置 (git-daemon)
git-daemon是按照git的自己的git协议进行访问git服务 1.git-daemon软件安装 软件仓库见 redhat 6 git 服务器 配置 (http) 2.配置git dae ...
- 网易云易盾中标浙报反作弊服务 助力浙江新闻App健康发展
欢迎访问网易云社区,了解更多网易技术产品运营经验. 近日,国内领先的智能业务安全平台网易云易盾和浙报传媒旗下"浙江新闻"达成合作,易盾将为浙江新闻客户端提供大数据反作弊服务,助力浙 ...