#abc349b. B - Commencement
B - Commencement
Score: points
问题陈述
一个由小写英文字母组成的字符串 如果满足以下所有整数 ( 不小于 )的属性,则称其为一个好字符串:
- 在 中恰好有正好零个或正好两个不同的字母出现恰好 次。
给定一个字符串 ,请确定它是否是一个好字符串。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
A string consisting of lowercase English letters is a good string if and only if it satisfies the following property for all integers not less than :
- There are exactly zero or exactly two different letters that appear exactly times in .
Given a string , determine if it is a good string.
Constraints
- is a string of lowercase English letters with a length between and , inclusive.
Input
The input is given from Standard Input in the following format:
Output
Print Yes
if is a good string, and No
otherwise.
Sample Input 1
commencement
Sample Output 1
Yes
For the string commencement
, the number of different letters that appear exactly times is as follows:
- : two letters (
o
andt
) - : two letters (
c
andn
) - : two letters (
e
andm
) - : zero letters
Therefore, commencement
satisfies the condition of a good string.
Sample Input 2
banana
Sample Output 2
No
For the string banana
, there is only one letter that appears exactly one time, which is b
, so it does not satisfy the condition of a good string.
Sample Input 3
ab
Sample Output 3
Yes