hzau 1210 Happiness

鸡兄今天非常开心,因为他得到了N块饼干,味道为A或B。这些饼干被放入一个盒子中,每次只能取出一块。如果连续取出A和B饼干,鸡兄就能将它们组合起来并快乐地吃掉。每成功组合一次A和B饼干,鸡兄的幸福感就会增加1。给定盒子中饼干的排列方式,请计算当所有饼干都被取出时鸡兄的幸福感。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1210: Happiness

Time Limit: 1 Sec  Memory Limit: 1280 MB
Submit: 1149  Solved: 301
[Submit][Status][Web Board]

Description

       Chicken brother is very happy today, because he attained N pieces of biscuits whose tastes are A or B. These biscuits are put into a box. Now, he can only take out one piece of biscuit from the box one time. As we all know, chicken brother is a creative man. He wants to put an A biscuit and a B biscuit together and eat them. If he take out an A biscuit from the box and then he take out a B biscuit continuously, he can put them together and eat happily. Chicken brother’s happiness will plus one when he eat A and B biscuit together one time.

      Now, you are given the arrangement of the biscuits in the box(from top to bottom) ,please output the happiness of Chicken Brother when he take out all biscuit from the box. 

Input

       The first line is an integer indicates the number of test cases.

       In each case, there is one line includes a string consists of characters ‘A’ and ‘B’.

       The length of string is not more than 1000000. 

Output

     For each test case:

    The first line output “Case #k:", k indicates the case number.    

    The second line output the answer. 

Sample Input

1
ABABBBA

Sample Output

Case #1:
2

HINT

 

转载于:https://www.cnblogs.com/bofengyu/p/6790520.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值