博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Check the string
阅读量:4627 次
发布时间:2019-06-09

本文共 1860 字,大约阅读时间需要 6 分钟。

A has a string consisting of some number of lowercase English letters 'a'. He gives it to his friend B who appends some number of letters 'b' to the end of this string. Since both A and B like the characters 'a' and 'b', they have made sure that at this point, at least one 'a' and one 'b' exist in the string.

B now gives this string to C and he appends some number of letters 'c' to the end of the string. However, since C is a good friend of A and B, the number of letters 'c' he appends is equal to the number of 'a' or to the number of 'b' in the string. It is also possible that the number of letters 'c' equals both to the number of letters 'a' and to the number of letters 'b' at the same time.

You have a string in your hands, and you want to check if it is possible to obtain the string in this way or not. If it is possible to obtain the string, print "YES", otherwise print "NO" (without the quotes).

Input

The first and only line consists of a string SS (1|S|5000). It is guaranteed that the string will only consist of the lowercase English letters 'a', 'b', 'c'.

Output

Print "YES" or "NO", according to the condition.

Examples
input
aaabccc
output
YES
input
bbacc
output
NO
input
aabc
output
YES
Note

Consider first example: the number of 'c' is equal to the number of 'a'.

Consider second example: although the number of 'c' is equal to the number of the 'b', the order is not correct.

Consider third example: the number of 'c' is equal to the number of 'b'.

 

 

1 #include 
2 #include
3 int main() 4 { 5 int a,b,c,flag0,flag1,flag2,flag,i,len; 6 char s[5001]; 7 gets(s); 8 len=strlen(s); 9 a=0;10 b=0;11 c=0;12 flag0=0;13 flag1=0;14 flag2=0;15 flag=0;16 len=strlen(s);17 for(i=0; i

 

转载于:https://www.cnblogs.com/wkfvawl/p/9215418.html

你可能感兴趣的文章
机器学习算法基础知识
查看>>
数据库分库分表(sharding)系列
查看>>
C++构造函数(一)
查看>>
用Quartus II Timequest Timing Analyzer进行时序分析 :实例讲解 (一)
查看>>
RK3399 BOX编译步骤
查看>>
SQL同时删除两张表中的数据
查看>>
在tomcat中用jndi配置数据源启动java web程序
查看>>
js获取当前时间
查看>>
Bzoj2110--Wc2011Xor
查看>>
2017 Multi-University Training Contest 3 hdu 6063
查看>>
jdk和jre的区别
查看>>
快速开发一个PHP扩展
查看>>
我的路子 - 发现游戏为模型的软件架构方式
查看>>
主攻ASP.NET.4.5 MVC4.0之重生:Entity Framework生成实体类步骤(十三)
查看>>
PHP-密码学算法及其应用-对称密码算法
查看>>
Linux-TCP/IP TIME_WAIT状态原理
查看>>
ScaleYViewPager
查看>>
Codeforces 504 A (Round #285 div.1 A) Misha and Forest
查看>>
适用于SharePoint 2013 的 CAML Desinger
查看>>
动态规划——洛谷_P1057传球游戏
查看>>