2203 亲和串
来源:互联网 发布:矩阵乘积求导法则 编辑:程序博客网 时间:2024/06/14 18:13
亲和串
Problem Description
人随着岁数的增长是越大越聪明还是越大越笨,这是一个值得全世界科学家思考的问题,同样的问题Eddy也一直在思考,因为他在很小的时候就知道亲和串如何判断了,但是发现,现在长大了却不知道怎么去判断亲和串了,于是他只好又再一次来请教聪明且乐于助人的你来解决这个问题。
亲和串的定义是这样的:给定两个字符串s1和s2,如果能通过s1循环移位,使s2包含在s1中,那么我们就说s2 是s1的亲和串。
Input
本题有多组测试数据,每组数据的第一行包含输入字符串s1,第二行包含输入字符串s2,s1与s2的长度均小于100000。
Output
如果s2是s1的亲和串,则输出”yes”,反之,输出”no”。每组测试的输出占一行。
Sample Input
AABCD
CDAA
ASD
ASDF
Sample Output
yes
no
AC代码:
#include<bits/stdc++.h>using namespace std;using LL=int64_t;int main(){ ios::sync_with_stdio(0); cin.tie(0); string s1,s2; while(cin>>s1>>s2) { if(s1.length()<s2.length()) cout<<"no"<<endl; else { string temp=s1+s1+s1; int flag=temp.find(s2); if(flag!=string :: npos) cout<<"yes"<<endl; else cout<<"no"<<endl; } } return 0;}
第一次用string::find()和string::npos,以前还一直以为结尾是用end()
阅读全文
0 0
- HDU 2203 亲和串
- HDU 2203 亲和串
- HDU - 2203 亲和串
- hdu 2203 亲和串
- hdu 2203 亲和串
- HDU 2203 亲和串
- HDU-亲和串-2203
- hdu 2203 亲和串
- hdu 2203 亲和串
- hdu 2203 亲和串
- hdu 2203 亲和串
- HDU 2203 亲和串
- HDU 2203【亲和串】
- hdu 2203 亲和串
- hdoj 2203 亲和串
- HDU 2203 亲和串
- hdu 2203亲和串
- HDU 2203 亲和串
- 二十四、DOM Elements
- AtomicInteger的原理浅析
- QT QTableWidget 用法总结
- reflectance 和 albedo 的区别
- docker学习笔记
- 2203 亲和串
- 04 mysql表的增删改查
- Python中numpy.clip();numpy.fabs()的用法;以及math.pow()的说明
- 关于UML的一些学习
- rgba()和opacity的透明效果有什么不同?
- codeforces 459A
- 免费赚取比特币
- java创建对象的四种方式
- mysql5.7安装步奏