华中农业大学第五届程序设计大赛网络同步赛-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 ...
随机推荐
- LOJ#3093. 「BJOI2019」光线(递推+概率期望)
题面 传送门 题解 把\(a_i\)和\(b_i\)都变成小数的形式,记\(f_i\)表示\(1\)单位的光打到第\(i\)个玻璃上,能从第\(n\)个玻璃下面出来的光有多少,记\(g_i\)表示能从 ...
- DZY Loves Math(莫比乌斯反演)
\(x=p_1^{\alpha_1}p_2^{\alpha_2}...p_c^{\alpha_c}\) \(f(x)=\max(\alpha_1,\alpha_2,...,\alpha_c)\) \( ...
- Iframe高度自适应(兼容IE/Firefox、同域/跨域)
在实际的项目进行中,很多地方可能由于历史原因不得不去使用iframe,包括目前正火热的应用开发也是如此. 随之而来的就是在实际使用iframe中,会遇到iframe高度的问题,由于被嵌套的页面长度不固 ...
- 课程一(Neural Networks and Deep Learning)总结——2、Deep Neural Networks
Deep L-layer neural network 1 - General methodology As usual you will follow the Deep Learning metho ...
- 小程序/js监听输入框验证金额
refundAmoutInput: function(event){ var value = event.detail.value; if (value.split('.')[0].length &g ...
- spring-boot-starter-actuator
首先在pom中添加依赖 pom.xml <?xml version="1.0" encoding="UTF-8"?> <project xml ...
- ASP.NET WebAPI Bearer Authorization
使用VS2015新建一个WebApi项目. 关键的配置在Startup.Auth.cs里 public partial class Startup { public static OAuthAutho ...
- linux解决病毒系列之一,删除十字符libudev.so病毒文件
前两天被服务器商通知服务器带宽流量增加,我想了想我们服务走的内网,没有什么大的带宽占用,于是我马上登录服务器. 用top命令查看运行情况,我擦,有一个进程吃了很高的cup,于是我赶紧用kill -9 ...
- 百度2015校园招聘面试题回忆录(成功拿到offer)
引言 盼望着,盼望着……今年终于轮到我找工作了,还深深记得去年跟在师兄后面各种打酱油的经历,当时觉得找工作好难啊,怎么面一个败一个,以后还能找到工作不? 不过当时的失败也是理所当然的,那时候没有做任何 ...
- 合并两个数组并去重(ES5和ES6两种方式实现)
合并两个数组并去重(ES5和ES6两种方式实现) ES6实现方式 let arr1 = [1, 1, 2, 3, 6, 9, 5, 5, 4] let arr2 = [1, 2, 5, 4, 9, 7 ...