L.Happiness

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 Description

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 Description

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

 #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm> using namespace std; int main()
{
int T;
string str;
cin>>T;
for(int kase = ; kase <= T; kase++)
{
cin>>str;
int len = str.length(), ans = ;
for(int i = ; i < len-; i++)
if(str[i] == 'A' && str[i+] == 'B')
ans++;
cout<<"Case #"<<kase<<":"<<endl;
cout<<ans<<endl;
} return ;
}

华中农业大学第五届程序设计大赛网络同步赛-L的更多相关文章

  1. 华中农业大学第五届程序设计大赛网络同步赛-K

    K.Deadline There are N bugs to be repaired and some engineers whose abilities are roughly equal. And ...

  2. 华中农业大学第五届程序设计大赛网络同步赛-G

    G. Sequence Number In Linear algebra, we have learned the definition of inversion number: Assuming A ...

  3. 华中农业大学第五届程序设计大赛网络同步赛-D

    Problem D: GCD Time Limit: 1 Sec  Memory Limit: 1280 MBSubmit: 179  Solved: 25[Submit][Status][Web B ...

  4. 华中农业大学第五届程序设计大赛网络同步赛-A

    Problem A: Little Red Riding Hood Time Limit: 1 Sec  Memory Limit: 1280 MBSubmit: 860  Solved: 133[S ...

  5. [HZAU]华中农业大学第四届程序设计大赛网络同步赛

    听说是邀请赛啊,大概做了做…中午出去吃了个饭回来过掉的I.然后去做作业了…… #include <algorithm> #include <iostream> #include ...

  6. (hzau)华中农业大学第四届程序设计大赛网络同步赛 G: Array C

    题目链接:http://acm.hzau.edu.cn/problem.php?id=18 题意是给你两个长度为n的数组,a数组相当于1到n的物品的数量,b数组相当于物品价值,而真正的价值表示是b[i ...

  7. 华中农业大学第四届程序设计大赛网络同步赛 G.Array C 线段树或者优先队列

    Problem G: Array C Time Limit: 1 Sec  Memory Limit: 128 MB Description Giving two integers  and  and ...

  8. 华中农业大学第四届程序设计大赛网络同步赛 J

    Problem J: Arithmetic Sequence Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 1766  Solved: 299[Subm ...

  9. 华中农业大学第四届程序设计大赛网络同步赛 I

    Problem I: Catching Dogs Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 1130  Solved: 292[Submit][St ...

随机推荐

  1. BZOJ NOIP提高组十连测第一场

    今天的题目一共拿了$180$分,感觉自己还是太菜了,二三两题只能骗到部分分 1.$String\ Master$ 题目大意:有两个字符串,在允许k次失配的情况下,求最长公共子串的长度 没什么好讲,直接 ...

  2. jQuery基础(1)

    一.jQuery的介绍 1.为什么要使用jQuery? 在用js写代码时,会遇到一些问题,如下: 1)window.onload 事件有事件覆盖的问题,因此只能写一个事件: 2)代码容错性差: 3)浏 ...

  3. apache ab

    ab -p postfile.json -T 'application/json' -n 100 -c 10 -v 2 http://192.168.1.103:3002/checkStashSlot ...

  4. HttpInvokerUtils

    package com.sprucetec.tms.utils; import org.slf4j.Logger;import org.slf4j.LoggerFactory; import java ...

  5. Shell - 简明Shell入门06 - 循环语句(Loop)

    示例脚本及注释 #!/bin/bash # for循环 for filename in t1 t2 t3 do touch $filename.txt echo "Create new fi ...

  6. flask_ Mongodb 的语法-排序

    MOngoDB的排序是挺有用的   ,跟MySQL有明显的区别 .. 它的原生语法的第一个参数为条件限定,第二个参数为排序字段 db.news.find({},{'_id':1})   #1是升序  ...

  7. 让PETSc跑得再快一些

    最近做了一个使用PETSc来求解线性方程组(Ax=b)的项目,把其中遇到的一些坑和解决方法记录下来.本文不介绍PETSc如何入门,而是给出一些能让PETSc运行得更快的编程细节.开始我只是简单地修改P ...

  8. [原创]K8 DNN密码解密工具(DotNetNuke Password Decrypt)

    工具: K8_DNN_Password_Decrypt编译: VS2012  C# (.NET Framework v2.0)组织: K8搞基大队[K8team]作者: K8拉登哥哥博客: http: ...

  9. odoo开发笔记 -- 用户配置界面如何增加模块访问权限

    在odoo设置界面,点击用户,进入用户配置界面,会看到: 访问权 | 个人资料菜单 在访问权 page菜单界面,可以看到系统预制的一些模块都会显示在这里, 那么,我们自己开发的模块如何显示在这块呢,从 ...

  10. Android 开发工具类 33_开机自运行

    原理:该类派生自 BroadcastReceiver,重载方法 onReceive ,检测接收到的 Intent 是否符合 BOOT_COMPLETED,如果符合,则启动用户Activity. imp ...