华中农业大学第五届程序设计大赛网络同步赛-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 = 1; kase <= T; kase++) { cin>>str; int len = str.length(), ans = 0; for(int i = 0; i < len-1; i++) if(str[i] == 'A' && str[i+1] == 'B') ans++; cout<<"Case #"<<kase<<":"<<endl; cout<<ans<<endl; } return 0; }
- 华中农业大学第五届程序设计大赛网络同步赛 H MathematicalGame
- 华中农业大学第五届程序设计大赛网络同步赛 C Friends
- 华中农业大学第五届程序设计大赛网络同步赛-K
- 华中农业大学第五届程序设计大赛网络同步赛-D
- 华中农业大学第五届程序设计大赛网络同步赛解题报告2(转)
- 华中农业大学第五届程序设计大赛网络同步赛解题报告(转)
- 华中农业大学第五届程序设计大赛网络同步赛-A
- 有一种绝望叫做无限PE hzau 1207 Candies (华中农业大学第五届程序设计大赛网络同步赛 I题)
- 华中农业大学第五届程序设计大赛网络同步赛
- 华中农业大学第五届程序设计大赛网络同步赛题解
- 华中农业大学第五届程序设计大赛网络同步赛-G
- [HZAU]华中农业大学第四届程序设计大赛网络同步赛
- 华中农业大学第四届程序设计大赛网络同步赛 Arithmetic Sequence
- 华中农业大学第四届程序设计大赛网络同步赛 J
- 华中农业大学第四届程序设计大赛网络同步赛 D题 Robbing Red Packets
- Problem J: Arithmetic Sequence——华中农业大学第四届程序设计大赛网络同步赛题目
- 华中农业大学第四届程序设计大赛网络同步赛解题报告
- 华中农业大学第四届程序设计大赛网络同步赛Problem I: Catching Dogs
- Contest1009 - 华中农业大学第四届程序设计大赛网络同步赛C,H,J
- 华中农业大学第四届程序设计大赛网络同步赛 G.Array C 线段树或者优先队列