华中农业大学第五届程序设计大赛网络同步赛-L
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的更多相关文章
- 华中农业大学第五届程序设计大赛网络同步赛-K
K.Deadline There are N bugs to be repaired and some engineers whose abilities are roughly equal. And ...
- 华中农业大学第五届程序设计大赛网络同步赛-G
G. Sequence Number In Linear algebra, we have learned the definition of inversion number: Assuming A ...
- 华中农业大学第五届程序设计大赛网络同步赛-D
Problem D: GCD Time Limit: 1 Sec Memory Limit: 1280 MBSubmit: 179 Solved: 25[Submit][Status][Web B ...
- 华中农业大学第五届程序设计大赛网络同步赛-A
Problem A: Little Red Riding Hood Time Limit: 1 Sec Memory Limit: 1280 MBSubmit: 860 Solved: 133[S ...
- [HZAU]华中农业大学第四届程序设计大赛网络同步赛
听说是邀请赛啊,大概做了做…中午出去吃了个饭回来过掉的I.然后去做作业了…… #include <algorithm> #include <iostream> #include ...
- (hzau)华中农业大学第四届程序设计大赛网络同步赛 G: Array C
题目链接:http://acm.hzau.edu.cn/problem.php?id=18 题意是给你两个长度为n的数组,a数组相当于1到n的物品的数量,b数组相当于物品价值,而真正的价值表示是b[i ...
- 华中农业大学第四届程序设计大赛网络同步赛 G.Array C 线段树或者优先队列
Problem G: Array C Time Limit: 1 Sec Memory Limit: 128 MB Description Giving two integers and and ...
- 华中农业大学第四届程序设计大赛网络同步赛 J
Problem J: Arithmetic Sequence Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1766 Solved: 299[Subm ...
- 华中农业大学第四届程序设计大赛网络同步赛 I
Problem I: Catching Dogs Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 1130 Solved: 292[Submit][St ...
随机推荐
- sync.Pool 资源池
sync.Pool type Pool struct { // 可选参数New指定一个函数在Get方法可能返回nil时来生成一个值 // 该参数不能在调用Get方法时被修改 New func() in ...
- Eclipse连接MuMu模拟器 方便 测试 查日志
Eclipse连接MuMu模拟器 方便 测试 查日志 问题由来 真机测试麻烦(首先你得拿一部手机,然后在用数据线连接电脑和手机...) 解决流程 确保打开MuMu模拟器和Eclipse的DDMS功能 ...
- hdu5745--La Vie en rose (DP+bitset)
好题,学到新姿势! 题意:给两个字符串 a 和 b ,b可以进行变换,规则是可以任意交换相邻两个字符的位置,但是不可以有交叉(例如3和4交换,5和6交换 互不影响,但是2和3,3和4就不可以).求a中 ...
- 安装SVN并进行汉化的详细步骤
安装SVN并进行汉化的详细步骤 SAE提供了不同的代码部署方式,可以分为两类:一是通过SVN客户端部署,这是SAE推荐的代码部署方法.另一个是通过非SVN客户端部署,即在线代码在线编辑器和推荐应用安装 ...
- SpaceSyntax【空间句法】之DepthMapX学习:第三篇 软件介绍与一般分析流程图
上篇讲啥来着?好像讲了数据的输入以及一些核心的概念.这篇讲软件长什么样,做那几种分析的步骤如何. 博客园/B站/知乎/CSDN @秋意正寒(我觉得这一篇肯定很多盗图的,那么我在版头加个本篇地址吧)ht ...
- odoo开发笔记:抛出警告的方式
上边rase 加3种写法,都能实现,跑出警告的功能.
- 机器人之路的第一小步:录音+语音识别(语音转文字),大小600K(免费下载)!
机器人之路的第一小步:录音+语音识别(语音转文字),大小600K,本人出品! 机器人之路的第一小步:录音+语音识别,准确率还不是特别高,不过普通话标准的话,识别准确率还是不错的,大家可以体验一下,请下 ...
- Identity Server4学习系列四之用户名密码获得访问令牌
1.简介 Identity Server4支持用户名密码模式,允许调用客户端使用用户名密码来获得访问Api资源(遵循Auth 2.0协议)的Access Token,MS可能考虑兼容老的系统,实现了这 ...
- i=i+1,i+=1,i++哪个执行效率最高?为什么?
(1)i=i+1最低,它的执行过程如下:读取右i的地址i+1读取左i的地址将右值传给左边的i(编译器并不认为左右i的地址相同)(2)i+=1其次,它的执行过程如下:读取左x的地址i+1将得到的值传给i ...
- 在Postgresql中添加新角色(Role)
Postgresql安装完成之后,默认会创建名为postgres的用户.角色(Role)和数据库(Database).而使用你自己原有的用户运行psql时会提示错误. bob@localhost:~$ ...