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有若干个)的最小数的最大值. 分析 这是一道用了 ...
随机推荐
- mybatis中in查询
xml配置 : <select id="selectPostIn" resultType="dasyskjcdtblVo"> SELECT SYS_ ...
- 向vsftp服务器上传文件报“550 Permission denied”错误的解决办法
上传文件: ftp> mput db.iso 550 Permission denied 原因:vsftp默认配置不允许上传文件. 解决:修改/etc/vsftpd.conf 将“write_e ...
- 在Linux下adb连接不上android手机的终极解决方案
转自: http://blog.csdn.net/liuqz2009/article/details/7942569 1.做android开发的过程,碰到了Linux下adb识别不了android设备 ...
- re.I re.L re.M re.S re.U re.X
- 关于handler的再次讨论
主要有两个问题,post方法和sendmessage方法有什么不同? 同一个handler对象发送的message只能发送给自己吗? 问题1: post方法,对于Handler的Post方式来说,它会 ...
- 如何取消WIN7的共享密码
如何取消WIN7的共享密码 把你的Guest帐号的密码设为空.如何设置呢? 1.右键“计算机”-“管理”-“本地用户和组”-“用户”-右键帐号“Guest”-“设置密码”,然后直接点击确定,不予设置密 ...
- 30-盐水(分段dfs)
链接:https://www.nowcoder.com/acm/contest/94/K来源:牛客网 时间限制:C/C++ 5秒,其他语言10秒 空间限制:C/C++ 131072K,其他语言2621 ...
- C++ 成员函数前和函数后加const修饰符区别
博客转载自: https://www.iteblog.com/archives/214.html 分析以下一段程序,阐述成员函数后缀const 和 成员函数前const 的作用 #include< ...
- ZROI2018普转提day6t3
传送门 分析 居然卡哈希数,万恶的出题人...... 感觉我这个方法似乎比较呆,我的代码成功成为了全网最慢的代码qwq 应该是可以直接哈希的 但由于我哈希学的不好又想练练线段树维护哈希,于是就写了个线 ...
- git clone Timed out 解决
因为不可抗拒的原因,在乌鲁木齐从 github 上面克隆项目时,会超时克隆不了. 使用 https 方式报错: $ git clone https://github.com/xxx.git Cloni ...