#abc346b. B - Piano

B - Piano

Score: 200200 points

问题陈述

有一个无限长的钢琴键盘。在这个键盘中是否存在一个连续的段落,由 WW 个白键和 BB 个黑键组成?

SS 为由字符串 wbwbwwbwbwbw 无限重复形成的字符串。

是否存在一个 SS 的子串,由 WWwBBb 组成?

SS 的子串是什么?SS 的子串是一个字符串,它可以通过将 SS 的第 ll 个、(l+1)(l+1) 个、\dots、第 rr 个字符按顺序连接起来形成,其中 llrr 是两个正整数,且 lrl\leq r

以上为大语言模型 kimi 翻译,仅供参考。

Problem Statement

There is an infinitely long piano keyboard. Is there a continuous segment within this keyboard that consists of WW white keys and BB black keys?

Let SS be the string formed by infinitely repeating the string wbwbwwbwbwbw.

Is there a substring of SS that consists of WW occurrences of w and BB occurrences of b?

What is a substring of SS? A substring of SS is a string that can be formed by concatenating the ll-th, (l+1)(l+1)-th, \dots, rr-th characters of SS in this order for some two positive integers ll and rr (lr)(l\leq r).

Constraints

  • WW and BB are integers.
  • 0W,B1000\leq W,B \leq 100
  • W+B1W+B \geq 1

Input

The input is given from Standard Input in the following format:

WW BB

Output

If there is a substring of SS that consists of WW occurrences of w and BB occurrences of b, print Yes; otherwise, print No.

Sample Input 1

3 2

Sample Output 1

Yes

The first 1515 characters of SS are wbwbwwbwbwbwwbw. You can take the 1111-th through 1515-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 SS.

Sample Input 3

92 66

Sample Output 3

Yes

update @ 2024/5/16 17:17:46