AT水题String Rotation

简介: 题目描述You are given string S and T consisting of lowercase English letters.Determine if S equals T after rotation.That is, determine if S equals T after the following operation is performed some number of times:Operation: Let S=S1S2…S|S|. Change S to S|S|S1S2…S|S|−1.

题目描述


You are given string S and T consisting of lowercase English letters.

Determine if S equals T after rotation.

That is, determine if S equals T after the following operation is performed some number of times:

Operation: Let S=S1S2…S|S|. Change S to S|S|S1S2…S|S|−1.

Here, |X| denotes the length of the string X.

Constraints

·2≤|S|≤100

·|S|=|T|

·S and T consist of lowercase English letters.


输入


Input is given from Standard Input in the following format:
S
T


输出


If S equals T after rotation, print Yes; if it does not, print No.


样例输入


kyoto
tokyo


样例输出


Yes


提示


In the first operation, kyoto becomes okyot.

In the second operation, okyot becomes tokyo.

题意很简单,不过醉翁之意不在酒,想要记录下一种好玩的做法,很好理解。

有关substr函数的应用

附上大佬的链接:

https://blog.csdn.net/Velly_zheng/article/details/89712735?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522158423930019724848339647%2522%252C%2522scm%2522%253A%252220140713.130056874…%2522%257D&request_id=158423930019724848339647&biz_id=0&utm_source=distribute.pc_search_result.none-task


微信图片_20220528183641.png


#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize (2)
#pragma G++ optimize (2)
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define wuyt main
typedef long long ll;
#define HEAP(...) priority_queue<__VA_ARGS__ >
#define heap(...) priority_queue<__VA_ARGS__,vector<__VA_ARGS__ >,greater<__VA_ARGS__ > >
template<class T> inline T min(T &x,const T &y){return x>y?y:x;}
template<class T> inline T max(T &x,const T &y){return x<y?y:x;}
//#define getchar()(p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 1 << 21, stdin), p1 == p2) ? EOF : *p1++)
//char buf[(1 << 21) + 1], *p1 = buf, *p2 = buf;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();
if(c == '-')Nig = -1,c = getchar();
while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();
return Nig*x;}
#define read read()
const ll inf = 1e15;
const int maxn = 2e5 + 7;
const int mod = 1e9 + 7;
#define start int wuyt()
#define end return 0
start{
    /**
    int num[4];
    cin>>num[1]>>num[2]>>num[3];
    sort(num+1,num+4);
    cout<<num[2]-num[1]+num[3]-num[2];**/
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<s.size();i++)
    {
        if(s==t) {
            ans=1;
            break;
        }
        s=s.back()+s.substr(0,s.size()-1);
    }
    if(ans==1) printf("Yes\n");
    else printf("No\n");
    end;
}
目录
相关文章
|
存储 SQL 关系型数据库
【BUG记录】Cause: java.sql.SQLException: Incorrect string value: '\xF0\x9F\x90\xA6' for column 'name' at row 1
在MySQL中遇到`Incorrect string value`错误通常是因为尝试插入的字符串包含不被数据库字符集支持的字符,如表情符号。错误根源是MySQL默认的utf8不支持4字节的UTF-8字符(如Emoji)。
1632 1
|
XML 关系型数据库 MySQL
Mysql插入emoji表情字符编码错误 Incorrect string value: ‘\xF0\x9F\x98\x84\xF0\x9F...‘ for column ‘comment‘ at r
今天在插入数据时发现emoji表情时数据库报错了,以前从来不会报错的,因为我设计表时从来都是如下设置:
343 0
|
SQL 关系型数据库 MySQL
MySQL数据库报错 > 1366 - Incorrect string value: ‘\xE6\xB1\x9F\xE6\x96\x87‘ for column ‘Teacher‘ at row 1
MySQL数据库报错 > 1366 - Incorrect string value: ‘\xE6\xB1\x9F\xE6\x96\x87‘ for column ‘Teacher‘ at row 1
364 0
MySQL数据库报错 > 1366 - Incorrect string value: ‘\xE6\xB1\x9F\xE6\x96\x87‘ for column ‘Teacher‘ at row 1
|
SQL Java 关系型数据库
|
SQL Web App开发 关系型数据库
java.sql.SQLException: Incorrect string value: '\xF0\x9F\x98\xB3' for column 'Content' at row 1
版权声明:本文为 testcs_dn(微wx笑) 原创文章,非商用自由转载-保持署名-注明出处,谢谢。 https://blog.csdn.net/testcs_dn/article/details/76199659 ...
2697 0
|
Web App开发 Java Apache
Freemarker Failed at: ${itm.creatTimeString?string("yyyy-MM... [in template
版权声明:本文为 testcs_dn(微wx笑) 原创文章,非商用自由转载-保持署名-注明出处,谢谢。 https://blog.csdn.net/testcs_dn/article/details/74990298 严重: Servlet.
1505 0
|
Web App开发 Java Apache
Freemarker Failed at: ${itm.creatTimeString?string(&quot;yyyy-MM... [in template
p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px 'Helvetica Neue'; color: #454545} p.p2 {margin: 0.
1783 0
|
20天前
|
编解码 Java 开发者
Java String类的关键方法总结
以上总结了Java `String` 类最常见和重要功能性方法。每种操作都对应着日常编程任务,并且理解每种操作如何影响及处理 `Strings` 对于任何使用 Java 的开发者来说都至关重要。
165 5
|
4月前
|
存储 编译器 C语言
关于string的‘\0‘与string,vector构造特点,反迭代器与迭代器类等的讨论
你真的了解string的'\0'么?你知道创建一个string a("abcddddddddddddddddddddddddd", 16);这样的string对象要创建多少个对象么?你知道string与vector进行扩容时进行了怎么的操作么?你知道怎么求Vector 最大 最小值 索引 位置么?
100 0