#abc232b. B - Caesar Cipher
B - Caesar Cipher
Score : points
问题描述
Takahashi 拥有一个由小写英文字母组成的字符串 。
他将在该字符串上执行以下操作一次。
- 首先,选择一个非负整数 。
- 然后,将 中的每个字符向右移动 位(见下文)。
这里,
a向右移动 位是b;b向右移动 位是c;c向右移动 位是d;y向右移动 位是z;z向右移动 位是a。
例如,b 向右移动 位是 f,而 y 向右移动 位是 b。
已给出一个字符串 。确定 Takahashi 是否可以通过上述操作使 等于 。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Takahashi has a string consisting of lowercase English letters.
On this string, he will do the operation below just once.
- First, choose a non-negative integer .
- Then, shift each character of to the right by (see below).
Here,
ashifted to the right by isb;bshifted to the right by isc;cshifted to the right by isd;yshifted to the right by isz;zshifted to the right by isa.
For example, b shifted to the right by is f, and y shifted to the right by is b.
You are given a string . Determine whether Takahashi can make equal by the operation above.
Constraints
- Each of and is a string of length between and (inclusive) consisting of lowercase English letters.
- The lengths of and are equal.
Input
Input is given from Standard Input in the following format:
Output
If Takahashi can make equal , print Yes; if not, print No.
Sample Input 1
abc
ijk
Sample Output 1
Yes
When Takahashi chooses ,
ais shifted to the right by and becomesi,bis shifted to the right by and becomesj,cis shifted to the right by and becomesk,
and now and are equal.
Therefore, he can make equal , so Yes should be printed.
Sample Input 2
z
a
Sample Output 2
Yes
Choosing makes and equal.
Note that the letter on the right of z is a.
Sample Input 3
ppq
qqp
Sample Output 3
No
There is no non-negative integer that he can choose to make equal , so No should be printed.
Sample Input 4
atcoder
atcoder
Sample Output 4
Yes
Choosing makes and equal.
update @ 2024/3/10 10:06:07