#abc346b. B - Piano
B - Piano
Score: points
问题陈述
有一个无限长的钢琴键盘。在这个键盘中是否存在一个连续的段落,由 个白键和 个黑键组成?
设 为由字符串 wbwbwwbwbwbw
无限重复形成的字符串。
是否存在一个 的子串,由 个 w
和 个 b
组成?
的子串是什么? 的子串是一个字符串,它可以通过将 的第 个、 个、、第 个字符按顺序连接起来形成,其中 和 是两个正整数,且 。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
There is an infinitely long piano keyboard. Is there a continuous segment within this keyboard that consists of white keys and black keys?
Let be the string formed by infinitely repeating the string wbwbwwbwbwbw
.
Is there a substring of that consists of occurrences of w
and occurrences of b
?
What is a substring of ? A substring of is a string that can be formed by concatenating the -th, -th, , -th characters of in this order for some two positive integers and .
Constraints
- and are integers.
Input
The input is given from Standard Input in the following format:
Output
If there is a substring of that consists of occurrences of w
and occurrences of b
, print Yes
; otherwise, print No
.
Sample Input 1
3 2
Sample Output 1
Yes
The first characters of are wbwbwwbwbwbwwbw
. You can take the -th through -th characters to form the string bwwbw
, which is a substring consisting of three occurrences of w
and two occurrences of b
.
Sample Input 2
3 0
Sample Output 2
No
The only string consisting of three occurrences of w
and zero occurrences of b
is www
, which is not a substring of .
Sample Input 3
92 66
Sample Output 3
Yes
update @ 2024/5/16 17:17:46